Work effectively with AI coding agents. Understand them as language models running in a tool loop with limited context, which is why they guess, game the visible signal and report confidently. Recognise the shortcut and correctness tells in their code across Python, TypeScript/JavaScript, Rust, Java and Go, and know the damage each one does later. Verify changes instead of trusting them, review diffs fast for quality and security, judge when work is truly finished, and choose, design and steer tasks so agents can finish them well.
String-built SQL, shell commands and HTML
card 3 of 6
The tells and their fixes
builds on: Trust boundaries and untrusted input
**Tell:** an untrusted value pasted into text that a database, shell or browser will parse. Look for:
- SQL built with f-strings, `+`, `%`, `.format`, template literals, `fmt.Sprintf` or `String.format`
- `shell=True`, `os.system`, Node `exec`, or `sh -c` with a value inside
- `innerHTML`, `dangerouslySetInnerHTML`, `v-html` or `|safe`. For example, `innerHTML` turns a name like `<img src=x onerror=alert(1)>` into a live element whose `onerror` script runs.
**Fix:** pass the value as data, using placeholders, argument arrays, `textContent` or auto-escaping templates. Table and column names can't be placeholders, so check them against an allowlist.
Lesson goal: Spot injection risks in agent code: f-string or concatenated SQL, `shell=True` or `exec` with interpolated input, and `innerHTML` or unescaped templates. Replace each with parameterised queries, argument arrays or safe encoding. ·
the whole lesson