Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ scanning, application execution, image decoding or exploit payloads.
## Project map

- `sharp_rsvg_rce_check.py`: generated, standalone Python 3.10+ executable.
- `src/checker.py`, `vendor/common.py`: product logic and vendored evidence/report helpers.
- `src/checker.py`, `src/adapters.py`, `vendor/common.py`: product logic and vendored evidence/report helpers.
- `rules/snapshot.json`: dated, source-linked enabled rule snapshot.
- `tools/build.py`: deterministic single-file build and release checksums.
- `test_assessment.py`, `test_contract.py`: synthetic offline behavior tests.
Expand Down
65 changes: 64 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ python sharp_rsvg_rce_check.py --help
git diff --check
```

Tests use synthetic local fixtures. CI is configured for Python 3.10 and 3.14 on Linux, Windows and macOS; assess its result for the exact published commit separately from local verification. Edit `src/checker.py`, `vendor/common.py` or `rules/snapshot.json`, then rebuild with `python tools/build.py`. The generated checker has no runtime dependency on another repository.
Tests use synthetic local fixtures. CI is configured for Python 3.10 and 3.14 on Linux, Windows and macOS; assess its result for the exact published commit separately from local verification. Edit `src/checker.py`, `src/adapters.py`, `vendor/common.py` or `rules/snapshot.json`, then rebuild with `python tools/build.py`. The generated checker has no runtime dependency on another repository.

## License

Expand All @@ -79,3 +79,66 @@ Built by [CompleteTech LLC](https://complete.tech) · Innovation at Every Integr
An interruption after a complete report is published preserves that report and exits 130.

If an interrupt leaves file publication indeterminate, the checker exits 130 without retrying. Inspect the output before retrying; the diagnostic does not establish whether publication succeeded.

## Explicit local metadata and source adapters

```sh
python sharp_rsvg_rce_check.py --npm-lock examples/package-lock.example.json --evidence-root examples
python sharp_rsvg_rce_check.py --source examples/source.example.js --evidence-root examples --format html
python sharp_rsvg_rce_check.py --node-elf path/to/node --evidence-root path/to
python sharp_rsvg_rce_check.py --sbom path/to/bom.json --evidence-root path/to
```

The repeatable `--npm-lock`, `--sbom`, `--node-elf` and `--source` options require
`--evidence-root`. Selected files must resolve inside that directory; paths in
reports are relative. They may accompany existing inventory/version inputs, but
produce separate generated `adapter-*` asset records. Generated identifiers must
not collide with supplied inventory IDs. No directory search, package-manager
operation, application import, native execution or image decoding occurs.

All adapter results remain `unknown` with `not_tested` exploitability. Metadata
cannot identify a deployed native-library selection or publisher patch
provenance. It never fills operator preconditions, changes a separate version
assessment or establishes effective mitigation. The existing schema 1.0 evidence
contract carries these observations as inventory/source evidence and locations;
JSON, CSV and HTML use the same validated records.

- npm lock v1/v2/v3: extract Sharp package version observations, including nested
instances and explicit aliases. Linked/malformed/qualified identities stay
unknown. Legacy v2 dependency records are separate uncertain observations,
never used to clear a conflicting primary entry. Registry URLs and scripts
are not collected. Empty supported coverage does not establish absence.
- SBOM: support JSON CycloneDX 1.4/1.5/1.6 and SPDX 2.2/2.3 Sharp/librsvg package
metadata. Names and versions remain supplied metadata, not linkage evidence;
no external references are fetched and no package paths are opened.
- ELF: read the identification/header, at most 1,024 standard-size program
headers and one interpreter string (512 bytes maximum). Support ELF32/64 in
both byte orders; bound file size to 2 GiB and metadata reads to 58 KiB. Reject
truncated/out-of-file tables/segments, duplicate interpreters, extended header
counts and unsupported layouts. ET_DYN with an interpreter is a dynamic
executable candidate; ET_DYN alone can also be a shared library or static PIE.
ET_EXEC and interpreter basename hints are reported without asserting Node
identity, loaded libc, runtime PIE, patch state or safety. Exact loader paths
are not reported. Other hardening features are not analyzed.
- Source: explicitly select JS/TS files. Simple Sharp default imports/CommonJS
bindings identify factory and block/unblock call candidates with relative
lines. An SVG-loader marker in a bounded local window can belong to unrelated
code. No match, missing marker, unknown options, inactive blocks, shadowing,
ordering or dynamic syntax never establishes effective blocking or input
trust. Templates and regex/division ambiguity require manual review. Source
strings/snippets are not reported.

Budgets: 100 adapter files, 1,000 combined result records, bounded 4 MiB JSON/text
reads and the existing JSON structure/depth limit; 10,000 package metadata
entries, 200,000 source tokens/file and 100 source candidates/file. Ordinary
regular-file checks require stable evidence copies, not a filesystem sandbox.
Output protection includes all selected evidence files and aliases, even with
--force. `--fail-on-unknown` includes these unknown adapter records.

Format provenance reviewed 2026-10-25: [Linux ELF header/program-header layouts](https://github.com/torvalds/linux/blob/master/include/uapi/linux/elf.h),
[npm lock grammar](https://docs.npmjs.com/cli/v11/configuring-npm/package-lock-json/),
[CycloneDX 1.6 schema](https://github.com/CycloneDX/specification/blob/master/schema/bom-1.6.schema.json) and
[SPDX package fields](https://spdx.github.io/spdx-spec/v2.3.1/package-information/).
The Linux Foundation gABI pages were access-denied; no access restriction was
bypassed. Advisory thresholds, rule date and native affected-range uncertainty
are unchanged. Edit `src/adapters.py` and rebuild with `python tools/build.py`.
2 changes: 1 addition & 1 deletion SHA256SUMS
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
1bcaeb2b9e138be1caeb38ecf622368f96b19180c21bdc305818907f085841c6 sharp_rsvg_rce_check.py
8e1f8aa20f18eff0ab83c4d3a30b96923107215b44ea3ed243ce0c0b8c06e5ad sharp_rsvg_rce_check.py
dbcee01397d62d0017fea9319fcb8d59a36b5bf0dfe16556f890cca498c848f6 rules/snapshot.json
4 changes: 4 additions & 0 deletions docs/IMPLEMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ The original research foundation is preserved in Git history and `advisory.json`
- [ ] Complete independent review and verify hosted CI for the exact final PR commit before merge.

No real system was assessed during implementation. Local verification, hosted CI and independent review are separate evidence. A rule enabled in this implementation does not establish live exposure, exploitation or production readiness.

## Local metadata adapters (2026-10-25)

Implemented bounded npm/SBOM package observations, explicit ELF header/program metadata inspection and Sharp source input/block/unblock candidates. Results preserve the existing schema and remain separate unknown records; no runtime precondition, effective mitigation or native patch provenance is inferred. Synthetic ELF32/64/endian/layout/truncation, metadata/link/SBOM, source inactivity, output-protection/parity and standalone tests are included. GitHub Copilot review and exact-head CI are required before merge.
4 changes: 3 additions & 1 deletion docs/METHODOLOGY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Custom and global linkage require a separate decision. A fixed Sharp package can

The advisory describes possible RCE under runtime conditions on glibc Linux and identifies two workarounds: blocking the SVG loader and running a Node executable compiled with PIE. The checker records these dimensions separately. Effective SVG blocking is a decoder mitigation; PIE mitigates the documented RCE condition while other impact from the memory bug may remain. Neither is treated as a fixed library. No assumption about PIE is derived from a Node version, package source, platform or a vendor's usual build policy.

An operator must establish the input path and effective process configuration independently. Merely finding a block call in source would not show that it applies before all image decoding, and this tool performs no such source scan. It accepts controlled observations without executing application code. Missing libc or PIE remains unknown; absent runtime conditions do not prove that the library memory bug is absent. All local reachability and exploitability remain `not_tested`, including when every reported condition is present.
An operator must establish the input path and effective process configuration independently. Merely finding a block call in source would not show that it applies before all image decoding, and the optional source scanner reports only separate lexical candidates. It accepts controlled observations without executing application code. Missing libc or PIE remains unknown; absent runtime conditions do not prove that the library memory bug is absent. All local reachability and exploitability remain `not_tested`, including when every reported condition is present.

Use build records, native linkage evidence and documented vendor patch provenance from the deployment being assessed. Keep conflicting evidence together; do not delete it or relabel a build to obtain a fixed result. Consult current upstream/vendor guidance, rebuild and redeploy as appropriate, and verify the effective deployed process separately. There is no public-website mode because ordinary response metadata cannot answer these questions.

The 2026-10-25 adapters emit separate unknown records: neither an ELF layout hint nor a lexical block call is an established runtime precondition or mitigation. Metadata package versions do not attest library selection or provenance. See the reference for exact format coverage and bounds.
63 changes: 63 additions & 0 deletions docs/REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,66 @@ A reported fixed component does not fail the unknown gate solely for missing opt
## Reproducibility

`rules/snapshot.json` is embedded by `tools/build.py`; reports include its canonical SHA-256 (sorted keys, compact JSON, UTF-8 and final newline). `SHA256SUMS` covers the generated single file and source snapshot. Checksums detect differences; they are not publisher signatures. `python tools/build.py --check` verifies both the generated source and release checksums. Runtime assessment never fetches a rule update.

## Explicit local metadata and source adapters

```sh
python sharp_rsvg_rce_check.py --npm-lock examples/package-lock.example.json --evidence-root examples
python sharp_rsvg_rce_check.py --source examples/source.example.js --evidence-root examples --format html
python sharp_rsvg_rce_check.py --node-elf path/to/node --evidence-root path/to
python sharp_rsvg_rce_check.py --sbom path/to/bom.json --evidence-root path/to
```

The repeatable `--npm-lock`, `--sbom`, `--node-elf` and `--source` options require
`--evidence-root`. Selected files must resolve inside that directory; paths in
reports are relative. They may accompany existing inventory/version inputs, but
produce separate generated `adapter-*` asset records. Generated identifiers must
not collide with supplied inventory IDs. No directory search, package-manager
operation, application import, native execution or image decoding occurs.

All adapter results remain `unknown` with `not_tested` exploitability. Metadata
cannot identify a deployed native-library selection or publisher patch
provenance. It never fills operator preconditions, changes a separate version
assessment or establishes effective mitigation. The existing schema 1.0 evidence
contract carries these observations as inventory/source evidence and locations;
JSON, CSV and HTML use the same validated records.

- npm lock v1/v2/v3: extract Sharp package version observations, including nested
instances and explicit aliases. Linked/malformed/qualified identities stay
unknown. Legacy v2 dependency records are separate uncertain observations,
never used to clear a conflicting primary entry. Registry URLs and scripts
are not collected. Empty supported coverage does not establish absence.
- SBOM: support JSON CycloneDX 1.4/1.5/1.6 and SPDX 2.2/2.3 Sharp/librsvg package
metadata. Names and versions remain supplied metadata, not linkage evidence;
no external references are fetched and no package paths are opened.
- ELF: read the identification/header, at most 1,024 standard-size program
headers and one interpreter string (512 bytes maximum). Support ELF32/64 in
both byte orders; bound file size to 2 GiB and metadata reads to 58 KiB. Reject
truncated/out-of-file tables/segments, duplicate interpreters, extended header
counts and unsupported layouts. ET_DYN with an interpreter is a dynamic
executable candidate; ET_DYN alone can also be a shared library or static PIE.
ET_EXEC and interpreter basename hints are reported without asserting Node
identity, loaded libc, runtime PIE, patch state or safety. Exact loader paths
are not reported. Other hardening features are not analyzed.
- Source: explicitly select JS/TS files. Simple Sharp default imports/CommonJS
bindings identify factory and block/unblock call candidates with relative
lines. An SVG-loader marker in a bounded local window can belong to unrelated
code. No match, missing marker, unknown options, inactive blocks, shadowing,
ordering or dynamic syntax never establishes effective blocking or input
trust. Templates and regex/division ambiguity require manual review. Source
strings/snippets are not reported.

Budgets: 100 adapter files, 1,000 combined result records, bounded 4 MiB JSON/text
reads and the existing JSON structure/depth limit; 10,000 package metadata
entries, 200,000 source tokens/file and 100 source candidates/file. Ordinary
regular-file checks require stable evidence copies, not a filesystem sandbox.
Output protection includes all selected evidence files and aliases, even with
--force. `--fail-on-unknown` includes these unknown adapter records.

Format provenance reviewed 2026-10-25: [Linux ELF header/program-header layouts](https://github.com/torvalds/linux/blob/master/include/uapi/linux/elf.h),
[npm lock grammar](https://docs.npmjs.com/cli/v11/configuring-npm/package-lock-json/),
[CycloneDX 1.6 schema](https://github.com/CycloneDX/specification/blob/master/schema/bom-1.6.schema.json) and
[SPDX package fields](https://spdx.github.io/spdx-spec/v2.3.1/package-information/).
The Linux Foundation gABI pages were access-denied; no access restriction was
bypassed. Advisory thresholds, rule date and native affected-range uncertainty
are unchanged. Edit `src/adapters.py` and rebuild with `python tools/build.py`.
1 change: 1 addition & 0 deletions examples/package-lock.example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"lockfileVersion":3,"packages":{"node_modules/sharp":{"version":"0.35.4"}}}
4 changes: 4 additions & 0 deletions examples/source.example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Synthetic text fixture, never executed.
const image = require('sharp');
image.block({operation:['VipsForeignLoadSvg']});
image(operatorInput);
Loading
Loading