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 4 of 6

The agent's report endpoint

BAD. Follow `name`. It goes from `request.args` straight into a file path with no check. `?name=../config/.env` walks out of the folder (path traversal). Worse, `os.path.join` discards every earlier part when a later part is absolute, so `?name=/etc/passwd` opens exactly that file. The happy-path test with `q1.pdf` could never show this. Later cost: anyone who can reach the server can download your secrets and system files.
// Python
--- a/reports/views.py
+++ b/reports/views.py
@@ -1,1 +1,8 @@
 REPORT_DIR = "/srv/app/reports"
+
+@app.get("/report")
+def report():
+    name = request.args["name"]
+    path = os.path.join(REPORT_DIR, name)
+    with open(path, "rb") as f:
+        return f.read()
Terms on this card
path traversal
An attack that uses ../ or absolute paths in a file name to read or write files outside the intended folder.
os.path.join
Python function that joins path parts. If a later part is absolute, it discards all earlier parts.
request.args
In Flask, the query-string parameters of the current HTTP request, fully controlled by whoever sends it.
endpoint
A URL plus method (such as GET /items) that a web API answers requests on.
join
Blocking until a thread has finished, e.g. Python's `t.join()` or Java's `Thread.join()`.
Learn this step by step on Bytewise
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