Hidden Instructions
- Category
- Prompt Injection
- Confidence
- 60% confidence
- Finding
Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.
- Content
md - `open(path)` uses the platform's default encoding, not UTF-8: cp1252 on Windows, ASCII under `LANG=C` in a lean container. The same code reads a file on your laptop and raises `UnicodeDecodeError: ... byte 0x93 in position 12` in CI. Write `encoding="utf-8"` on every text `open`, `read_text`, `write_text`, and `subprocess` call (Core Rule 8). - Find the ones you missed: `python -X warn_default_encoding` (`python >=3.10`) emits an `EncodingWarning` at each site. `PYTHONUTF8=1` / `python -X utf8` forces UTF-8 process-wide as a stopgap for code you cannot edit; PEP 686 makes that the default in `python >=3.15`. - Files exported from Excel start with a BOM: read them with `encoding="utf-8-sig"` (strips it) — otherwise the first column name is `"id"` and every dict lookup on `"id"` fails. - `errors="replace"` belongs only at a display boundary. Applying it to data silently substitutes `�` and destroys the bytes you needed. - Bytes in, bytes out: read binary (`"rb"`) when the content is not text. Round-tripping unknown bytes through `str` corrupts them unless you use `errors="surrogateescape"`, which is also how paths with invalid encodings survive. - Unicode equality is not byte equality: macOS filesystems hand back NFD (`e` + combining accent) where Linux gives NFC. Two visually identical names compare unequal. Normalize before comparing: `unicodedata.normalize("NFC", s)`.
