Blog·
Composer's Perforce bug was ten years old when it got a CVE. The path was there the whole time.
On 15 April 2026, Composer, the PHP package manager, published two advisories against its Perforce support: CVE-2026-40176 and CVE-2026-40261. Both are command injection. Both affect every release from 1.0, in 2016, to 2.9.5. They were fixed in 2.9.6 and 2.2.27.
What went wrong is short to describe. Composer's Perforce driver builds p4 shell commands from strings it did not write:
Perforce::generateP4Command()put the port, user and client from a repository URL into the command without escaping (CVE-2026-40176). A maliciouscomposer.jsonin a project you open is enough.Perforce::syncCodeBase()appended a package's source reference to the command the same way (CVE-2026-40261). Here the strings come from package metadata, which any Composer repository can serve, and installing from source is the default for dev versions.
According to both advisories, neither needs Perforce to be installed.
The bug is not interesting. What is interesting is how long it waited.
The edge existed before the advisory did
A memory corruption bug hides in the arithmetic. You find it by fuzzing, or by someone being very clever. This one did not hide. In every release since 1.0 there has been a line of code where a string from outside goes in and a shell command comes out, with nothing in between. That is a fact about the code, not about anyone's knowledge of it. It was as true in 2016 as it was on the day the advisory went out.
An analysis that follows data through code can see that line. It does not need to know the bug exists. It needs only two things: where outside input enters, and which operations are dangerous when it reaches them. Shells, deserializers, file paths, outgoing requests. If there is a path from one to the other and no check on the way, it says so.
That is the bet behind vdb harden. Advisories are filed for paths like this one after someone notices. The path is there before.
What harden would have said about Composer: nothing
We should be precise here, because this is exactly where it is easy to overclaim.
harden does not analyze PHP. It reads Python and follows arguments into PyPI packages. Pointed at a PHP project, it has nothing to say.
And even in Python, this is not quite harden's case. Composer is a tool you run, not a library your code calls. harden starts from a call in your code and follows its arguments into your dependencies. When the dangerous input is a composer.json you opened from a stranger, there is no call site of yours to start from.
So harden would not have caught these two CVEs. What it can show is the same shape in the place it does look.
The same shape, in Python
The Python twin of Composer's VCS driver is GitPython, which builds git commands from what you pass it. It has its own history here: CVE-2022-24439, a crafted URL to clone_from that reached command execution, fixed in 3.1.30. That fix was incomplete, and CVE-2023-40267 closed the rest in 3.1.32.
Here is a service with a feature many services have. It imports a repository from a URL the user types in:
import git
from flask import Flask, request
app = Flask(__name__)
@app.post("/import")
def import_repo():
url = request.form["repo_url"]
git.Repo.clone_from(url, "/srv/imports/latest")
return {"ok": True}
We pinned GitPython to 3.1.29, the release before the first fix, and ran harden on it:
<<HARDEN_OUTPUT>>
<<HARDEN_READING>>
Closing it at the call site
You cannot patch GitPython from your service, and you should not have to wait for its maintainers to notice. What you control is the boundary: the one line where your input goes in.
harden's fix for command execution is an allowlist at that line. It accepts only values you have listed, and refuses everything else, the empty list included:
def vdb_safe_arg(value, allowed):
"""Accept only an explicitly enumerated command argument."""
v = str(value)
if not allowed:
raise ValueError("a non-empty command allowlist is required")
if v not in allowed or "\0" in v:
raise ValueError("command argument not in allowlist")
return v
APPROVED = {"https://github.com/our-org/templates.git",
"https://github.com/our-org/examples.git"}
git.Repo.clone_from(vdb_safe_arg(url, APPROVED), "/srv/imports/latest")
This is blunt on purpose. Escaping is what both Composer and GitPython had to get right, and GitPython needed two attempts. An allowlist does not need to understand shell quoting, or git's option parser, or the ext:: transport. A value is either on the list or it does not get through. If your feature really must accept any URL, the list becomes a rule (scheme https, an approved host, no leading -), and you are back to writing a parser. That is a trade worth making knowingly.
Then vdb harden app.py --manifest requirements.txt --verify <path_id> re-runs the analysis and reports the path as closed only when the required defense is found at the boundary. It checks that the defense is there. It does not certify that your list is a good one.
The order matters as much as the wrapper. GitPython's advisories came years after clone_from first shipped. Composer's came ten years after 1.0. A wrapper at your call site works the same on the day before the advisory as on the day after.
Where the line is
This class of bug, outside text reaching a dangerous operation through a library's own code, is harden's ground. Here is what is not:
- Memory bugs in an interpreter or the operating system. A heap overflow in CPython, OpenSSL or the kernel is not a dataflow path between Python calls. harden has no way to see it, and a call-site wrapper does not stop it.
- Anything reached only through a C extension. There is no Python source to follow.
- Code that runs at install time. A malicious
setup.pyruns before any call site exists. Every report lists this as never defended. - Tools you run rather than code you call. That is the Composer case above.
- SQL injection. It is not one of harden's sink classes, so
sqlalchemy.text(user_sql)produces nothing. - Ecosystems other than PyPI, for now.
What we can and cannot claim
What this supports:
- Command injections like Composer's and GitPython's are a pattern that is present in the code long before the advisory. The edge from input to shell is not a secret. It is a line.
- In Python, harden follows that edge from your call site into the dependency, without needing a CVE, <<CLAIM_RESULT>>.
What it does not support:
- That harden would have caught the Composer CVEs. It does not read PHP, and those inputs did not pass through a call site of yours.
- That harden finds every such edge. Its reach comes from static summaries of each package. A pass-through the summarizer missed is a silent miss, and dynamic dispatch is handled by assuming the worst and saying so.
- That a flagged path is exploitable. On our own service, one lead in eleven was a real problem. A flagged path tells you where to read first.
The useful sentence is narrower than "finds vulnerabilities before they have CVEs". It is this: if your code hands outside input to a library that builds commands, queries or file paths from it, harden shows you that line, whether or not anyone has written an advisory about it yet. Then you decide what goes through.
To try it on your own code, see Hardening.
Comments
No comments yet. Corrections are especially welcome.
Sign in to comment. No account?Sign up — it is free.