[MEDIUM] fetch-openapi.sh: pass $OUT via sys.argv, not f-string in heredoc #2
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
From audit #1.
Problem
bin/fetch-openapi.sh:32-37embeds$OUTdirectly into a heredoc passed topython3 -c. IfOPENAPI_OUTwere ever attacker-controlled (currently a dev-only env var), an unbalanced quote in the filename would allow Python code injection.Remediation
Pass
$OUTto the embedded script viasys.argvrather than shell-level f-string substitution.Acceptance
fetch-openapi.shcallers continue to work unchanged.Effort: small.
Agent Evaluation
Feasibility: Trivial. The Python heredoc is 5 lines and only uses
$OUTonce.Impact: Closes the documented injection-shaped pattern. Real-world risk is low (developer-only env var) but the pattern is a footgun if the script is ever reused in CI with less-trusted inputs.
Effort: Small.
Recommendation: Accept.
Implementation plan
$OUTthroughsys.argv: Note the'PY'quoted heredoc delimiter — it stops the shell from doing any further interpolation inside, even if someone later adds another$VAR.OPENAPI_OUTenv var → file at that path — is preserved).OPENAPI_OUT=/tmp/foo.json bash bin/fetch-openapi.shagainst a live OpenAPI endpoint, confirm the file lands and the assertion line still prints.Evaluated #2 — Small, recommend accept (no decision branches; single approach).
Implemented #2 → commit
5b0bec8(heredoc now 'PY'-quoted, $OUT passed via sys.argv).