-
-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Security] Code execution risk when running cdxgen against untrusted repos #1328
Comments
Tasks
Stretch goals
|
This has now landed in the CVE database and is being reported by GitHub's security tab: |
I have started working on a container image called cdxgen-secure. The idea is to use Node.js permission api and disable automatic installations by default. |
@eran-medan Could you kindly help test the new secure mode including the As discussed in the below document, you can set an environment variable https://github.com/CycloneDX/cdxgen/blob/master/docs/PERMISSIONS.md Repotests workflow - cdxgen/.github/workflows/repotests.yml Line 742 in 6e066ee
cdxgen-secure container image can be executed as shown: docker run --rm -v /tmp:/tmp -v $(pwd):/app:rw -t ghcr.io/cyclonedx/cdxgen-secure:master cdxgen -r /app -o /app/bom.json -t java Testing stepsLimit write permissions to only temp directory and export NODE_OPTIONS='--permission --allow-fs-read="/var/folders/h5/43_6kqvs4w7cclqtdbpj_7g80000gn/T/*" --allow-fs-write="/var/folders/h5/43_6kqvs4w7cclqtdbpj_7g80000gn/T/*" --allow-fs-read="*" --allow-fs-write="/Volumes/Work/sandbox/issue-1328/*.json" --allow-child-process' Run cdxgen node /Volumes/Work/CycloneDX/cdxgen/bin/cdxgen.js -o bom.json $(pwd)
(node:36104) SecurityWarning: The flag --allow-child-process must be used with extreme caution. It could invalidate the permission model.
(Use `node --trace-warnings ...` to show where the warning was created)
SECURE MODE: DO NOT run cdxgen with FileSystemRead permission set to wildcard.
SECURE MODE: DO NOT run cdxgen with FileSystemWrite permission set to wildcard.
Scanning /Volumes/Work/sandbox/issue-1328
Performing babel-based package usage analysis with source code at /Volumes/Work/sandbox/issue-1328
Executing /Volumes/Work/sandbox/issue-1328/gradlew --build-cache --console plain --no-parallel properties in /Volumes/Work/sandbox/issue-1328.
Executing /Volumes/Work/sandbox/issue-1328/gradlew --build-cache --console plain --no-parallel :app:properties in /Volumes/Work/sandbox/issue-1328.
Parsing /Volumes/Work/sandbox/issue-1328/gradle/wrapper/gradle-wrapper.jar
Ignored jar gradle-wrapper.jar gradle-wrapper undefined
Unable to extract the component information from /Volumes/Work/sandbox/issue-1328/gradle/wrapper/gradle-wrapper.jar
Obtained 0 components and 0 dependencies after dedupe. gradle dependencies command will not get executed in secure mode by default and hence hello.txt will not get created. The SBOM would be empty. |
This is a design limitation, without an immediate fix.
Summary
(Rewritten for clarity)
npm install
, maven, gradle, and sbt commandsnpm install
(default behavior unless--no-install-deps
is passed), npm could be invoking more commands as per the scripts section in the package.json file present in the given codebase.POC
Timeline
8 Aug 2024 - Email received from the researcher.
8 Aug 2024 - Initial response: Known acceptable risk that is consistent with executing any CLI command including the package manager commands themselves.
19 Aug 2024 - Researcher shared more details about attacking SCA scanners that wrap cdxgen such as OWASP dep-scan.
26 Aug 2024 - GitHub Issue created.
Known workarounds
-v /tmp:/tmp
and-v $HOME:$HOME
), and a dedicated seccomp profiles.--no-install-deps
or--lifecycle pre-build
to prevent cdxgen from running install commands. This may not work for all package managers.The text was updated successfully, but these errors were encountered: