fix(deps): prevent CMake manifest injection - #235
Conversation
Encode metadata-derived manifest values as collision-safe CMake bracket arguments and comments. This keeps URLs, refs, paths, and operator names literal without narrowing supported Git source forms. Co-authored-by: Codex <noreply@openai.com> Signed-off-by: Wenqi Li <wenqil@nvidia.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
Included review availability: 3 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour. WalkthroughThe CMake manifest generator now emits metadata and module arguments as dynamically delimited bracket arguments. Unit tests cover delimiter collisions, multiline Git values, operator names, and local override paths. ChangesCMake manifest encoding
Estimated code review effort: 2 (Simple) | ~15 minutes Merge Risk: ⚪ Minimal · up to The change narrowly hardens generated CMake manifest values against injection while preserving supported Git source formats, and no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
Summary
Vulnerability confirmation
This issue is real and reachable. Local build paths used by build, install, and run parse project-controlled
metadata.jsonandmodules/module-sites.jsonvalues intoModuleDeprecords.write_external_operators_manifestpreviously interpolated those values into double-quoted CMake arguments, and the generated manifest is included during CMake configuration before FetchContent processes the dependency.A crafted Git URL can close the quoted argument and declaration, introduce a new CMake command, and make the remaining generated tokens part of a valid command. A
cmake -Preproduction reached the injected command before this change.Why this fixes it
CMake bracket arguments treat their contents literally: quotes, parentheses, backslashes, variable references, and newlines cannot alter the surrounding syntax.
_cmake_bracket_argumentchooses an equals-sign delimiter whose closing sequence does not occur in the value, preventing the value from terminating its own argument. The same encoding is applied consistently to Git URLs, refs, local paths, operator names, cache descriptions, and metadata-derived comments so another field cannot provide an equivalent breakout.This preserves accepted source formats instead of imposing a URL allowlist. It is independent defense in depth alongside #234, which separately requires immutable remote refs.
Testing
python -m pytest -q -o addopts='' tests/unit(494 passed, 1 skipped)PYTHONPATH=src PRE_COMMIT_HOME=/tmp/holoscan-cli-pre-commit-cache-mutable-refs python -m holoscan_cli lintcmake -Pwithout executing the injected commandAI-assisted: Created with Codex/GPT at the user's request.
Summary by CodeRabbit