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.
Trust boundaries and untrusted input
card 3 of 6
Checklist at every boundary
1. **Find it**: trace each value back. If any part came from outside, it is untrusted, even data from "our partner's API".
2. **Validate on entry**: check type, length and range, and match an allowlist of allowed shapes. Reject everything else.
3. **Keep data as data**: where the API allows it, pass the value as a separate argument or parameter. Never splice it into text that another program parses.
4. **Encode for the destination**: where it must go into text, encode it: HTML-escape for pages, URL-encode for links.
**Tell**: input concatenated into a path, query, command or markup. **Later cost**: an attacker reads or changes data, or runs commands.
Terms on this card
- allowlist
- A rule listing exactly which values or shapes are accepted. Everything else is rejected. It is safer than listing bad values to block.
- HTML-escape
- Replacing characters like <, > and & with safe codes so a browser shows text instead of running it as markup or script.
- URL-encode
- Replacing special characters in a value with %XX codes so it stays a single value inside a link or query string.
- match
- Rust expression that runs a different branch for each case of a value, e.g. Ok(..) versus Err(..).
- API
- Application programming interface: here, the server endpoint the page calls for data.
Lesson goal: Identify where data crosses from an untrusted source (users, network, files, third parties) into your code. Explain that injection bugs come from treating that data as code or commands, and that the defence is to validate and encode at the boundary. ·
the whole lesson