security: harden solver execution gates and 94-test suite#452
Draft
brightyorcerf wants to merge 1 commit intoEAPD-DRB:mainfrom
Draft
security: harden solver execution gates and 94-test suite#452brightyorcerf wants to merge 1 commit intoEAPD-DRB:mainfrom
brightyorcerf wants to merge 1 commit intoEAPD-DRB:mainfrom
Conversation
Collaborator
|
Thanks for this. We're prioritizing other work right now, so converting this to draft for the time being. We'll revisit when we're ready to pick these up. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issue
Existing related work reviewed
Overlap assessment
Why this PR should proceed
Patches a Critical Security Vulnerability: The v5.5 upstream sync introduced/modified several routes in
DataFileRoute.pythat failed to validate thecaserunnameinput against path traversal. Because this value ultimately flows intosubprocess.run()arguments for solver execution (in the/runendpoint), an attacker could escape the designatedres/sandbox (caserunname: "../../../../tmp/evil") and run shell processes from arbitrary directories, posing a severe system security risk.Zero Regressions & Strong Test Coverage: Adds 94 new test cases specifically targeting traversal payloads (including null-byte injection) across all 12 affected route handlers. The entire existing test suite continues to pass. This PR also thoroughly enforces
Config.validate_path()across all APIs that handle data files.Summary
What changed:
_validate_case_inputs()helper inDataFileRoute.pyto consistently validate bothcasenameandcaserunnameat the route boundary before any filesystem access or instantiation./generateDataFile,/createCaseRunand so on).{'glpk', 'cbc'}) for thesolverparameter in the/runendpoint to prevent command/solver injection./deleteCaseRunby placing thePermissionErrorhandler before its parent class (OSError), ensuring path validation failures return a400instead of a generic500.tests/test_path_traversal.py) with 94 tests verifying path traversal protections.Why:
casenamewas somewhat protected by theDataFile()constructor inheritingOsemosys.__init__,caserunnamewas completely ignored. A request constructed with a safecasenamebut a maliciouscaserunname(e.g.,../../../../etc/passwd) would successfully bypass checks and traverse the filesystem. Validating both inputs exactly at the route entry point eliminates this gap.Validation
Documentation
Scope check
OSeMOSYS/MUIOdependencyEAPD-DRB/MUIOGO:main(not upstream)Exception rationale
blank