Urgent.News

What's breaking now, across hundreds of outlets.

Tech

My shell-injection scanner flagged 3 of my own files. All 3 were wrong.

My shell-injection scanner flagged 3 of my own files. All 3 were wrong. I built a small static checker called sg audit . It finds the three call shapes that turn untrusted text into shell syntax: shell=True , os.system / os.popen , and a subprocess call whose first argument is a string instead of an argv list. Tonight I pointed it at our own source tree. 90 Python files, 6 findings, exit 1. Three…

A shell-injection scanner flagged three files within its own source tree, all of which were incorrectly marked as vulnerable. The author developed a small static checker called sg audit to identify three specific call shapes that convert untrusted text into shell syntax. After running sg audit on the source tree, it found 90 Python files with 6 findings, and 3 of those findings were real.

The three real findings were in different files within a demo service, and they were indeed genuine. Two of the findings were caused by using subprocess.run([BT] + args) and subprocess.run(["version", "-V"]), while the third was due to a named helper function named "run" within the same file that was also imported from subprocess.

The author emphasizes that while a scanner that constantly flags false positives can be annoying, it is crucial that it does not overlook real vulnerabilities. The author provides two potential fixes to address the false positives: inspecting the left operand of a binary operation to determine if it is a list or string literal, and resolving the name of bare function calls through the file's imports.

These changes would help differentiate between correct and incorrect usage of subprocess.run, allowing the scanner to be more reliable while still catching actual vulnerabilities.

Rewritten by urgent.news; may contain errors — check the original.

Read the original at dev.to →

Report a problem with this story

More in Tech

Why Strong SREs & Backend Engineers Struggle in Meta Production Engineering Interviews (5 Advanced Technical Traps)

Most experienced SREs, DevOps engineers, Systems Engineers, and Backend SWEs do not struggle in Meta Production Engineering (PE) interviews because they lack real-world experience.

  • Parsing process info from /proc/[pid]/stat and handling JSON telemetry in Python can be tricky
  • Guard against Boolean values and non-finite floats when validating JSON telemetry in Python

From sleep(5000) to a real UI check: five tests for desktop automation

A desktop automation can pass in a demo and still fail on a real workstation. Fixed delays, small layout changes, and retries that repeat the wrong action are common reasons.

  • Test flow when window and control are already visible
  • Introduce artificial delays to mimic slower machines
  • Render target unavailable to trigger failure scenario

More from Sunday 22 November →