Dev.to Security 🔐 Cybersecurity 👁 0 📖 3 min read

I ran my shell-injection scanner on my own repos. It flagged three of my files.

I spent last week doing something I did not expect to do: I ran my own shell-injection scanner over my own repositories, and it flagged three of my files. Not toy examples. Real files I had already pushed. One of them b

I spent last week doing something I did not expect to do: I ran my own shell-injection scanner over my own repositories, and it flagged three of my files.

Not toy examples. Real files I had already pushed. One of them built a shell string from an environment variable that, in a container, is attacker-controlled more often than people admit.

The uncomfortable part was what happened next. I fixed the three findings, re-ran the scanner, got a clean report, and then did what everyone does: nothing. The report sat in a directory. It proved something about a commit I will forget in two months. If a customer had asked me "is this safe", I would have forwarded a screenshot and felt fine about it. That is not evidence. That is a screenshot of an opinion.

Why I stopped trusting a chat log as proof

The problem with saying "our code is clean" is that the person saying it is the person who wrote the code, the statement expires the moment the repo moves, and nobody can check it later. So I built the thing I actually wanted to hand over: a report that names the exact rule catalogue it applied, quotes the offending line with its file and line number, hashes every file it read, and carries an HMAC signature over all of it.

Three properties matter to me:

It is dated. The report records the repository state it analysed by content hash, so six months from now you can tell whether the code you are running is the code that was checked.

It is signed. HMAC-SHA256 over the canonical payload. If someone edits a finding after the fact, verification fails. I can hand a customer a report and a key and they can check it themselves without asking me anything.

It says what it cannot do. The report lists its own limits in plain text: the taint analysis is intra-procedural with a conservative branch union, alias tracking through containers and attributes is limited, dynamic dispatch through getattr and dict lookups is not resolved, lambda and comprehension bodies are skipped, and the Bash side is a token-level heuristic rather than a real shell parser. Absence of findings is explicitly not evidence of absence of weaknesses.

That last part is the reason I trust it more than the alternatives. A tool that claims your code is safe is selling you something. A tool that tells you exactly where its reasoning stops is giving you something you can act on.

What it does not do

It does not certify anything. It is not a compliance attestation and not a guarantee. It finds patterns where attacker-controlled data reaches a dangerous sink, with quoted evidence and a CWE class, and it stops there. Whether a finding is exploitable in your deployment is still an engineering judgement, and the report is honest that it cannot make it for you.

Where it is

The scanner is Python, standard library only, 126 tests, MIT licensed. It reads Python with the AST and Bash at token level, resolves parameter and return taint across functions with a bounded fixpoint, and treats shlex.quote as the sanitiser it is.

pip install injection-audit
injection-audit init-key --out keys/audit.key
injection-audit scan ./src --key-file keys/audit.key --label my-service --out reports/
injection-audit verify reports/report-SIA-*.json --key-file keys/audit.key

Source and the full test suite are at https://github.com/derbaroser-eng/injection-audit

If you run it over your own tree and it finds something embarrassing in yours too, that is the intended experience. The first run is supposed to be uncomfortable.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.