Skip to content

Refactor GuidedRemediation to use os.Root - #2363

Merged
copybara-service[bot] merged 3 commits into
google:mainfrom
doyensec:scanner-gr-root-fs
Sep 6, 2026
Merged

copybara-service[bot] merged 3 commits into
google:mainfrom
doyensec:scanner-gr-root-fs

Conversation

@SzymonDrosdzol

Copy link
Copy Markdown
Collaborator

The fix ensures that Guided Remediation never touches hosts files outside of the scoped project by converting to using os.Root interface for file operations.

Please note, that this change makes some design choices for existing ReaderWriters suboptimal (e.g. guidedremediation/internal/manifest/maven/pomxml.go's GetReadWriter). However, this PR deliberately chooses to minimize the architectural changes in favor of making minimal changes required to enforce os.Root` usage.

…o prevent path traversal attacks

Use os.Root for manifest and lockfile reads and writes, preventing Maven
parents, npm workspaces, and recursive requirements from escaping
ProjectRoot.
@SzymonDrosdzol SzymonDrosdzol changed the title Conver GuidedRemediation to use os.Root Refactor GuidedRemediation to use os.Root Aug 14, 2026
@cuixq

cuixq commented Aug 18, 2026 •

Copy link
Copy Markdown
Collaborator

Thanks for this change! Using os.Root to sandbox manifest reads and writes is a great security improvement, however I am a bit unsure about the behavior change when ProjectRoot is not given:

Because ProjectRoot is an optional flag, users running Guided Remediation on a Maven child pom.xml will find that SCALIBR is not able to read or update local parent POMs (e.g. <relativePath>../pom.xml</relativePath>) without explicitly setting ProjectRoot. This makes ProjectRoot feel de facto required for standard Maven projects, which is a significant behavior change.

Could we consider:

  • A smarter default when ProjectRoot is not given? Detect the enclosing repository root (e.g. finding .git) or current working directory (os.Getwd()) before falling back to filepath.Dir(manifest). This keeps SCALIBAR securely sandboxed within os.Root while letting Maven projects work seamlessly.

  • More explicit documentation about the potential behavior change. If keeping filepath.Dir as the fallback, make it very clear in the documentation that without specifying ProjectRoot, parent pom.xml files outside the current directory cannot be located or updated during remediation.

@SzymonDrosdzol

Copy link
Copy Markdown
Collaborator Author

Thanks for the review @cuixq, great catch.

I added an upward search for the nearest enclosing Git repository when an explicit ProjectRoot is not provided. If none is found, we fall back to the directory containing the selected manifest.

I would be cautious about using the current working directory:

  • It defeats the security of os.Root when ran from hosts root (/) using a fulll path of the POM (os.Root would cover entire filesystem in such a case)
  • CWD is process-global state and may be unrelated to the selected manifest. If it is not an ancestor of the manifest, the manifest would fall outside the root, introducing unexpected behavior

Please let me know the desired direction. I'll be happy to expand the docs if needed too.

@cuixq cuixq left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for adding the Git root detection and updating the documentation - the reason for not using os.Getwd() makes sense.

@copybara-service
copybara-service Bot merged commit 2378d01 into google:main Sep 6, 2026
18 checks passed
schubydoo pushed a commit to schubydoo/clauster that referenced this pull request Sep 14, 2026
This PR contains the following updates:

| Package | Update | Change | OpenSSF |
|---|---|---|---|
| [google/osv-scanner](https://redirect.github.com/google/osv-scanner) |
minor | `v2.5.1` → `v2.6.0` | [![OpenSSF
Scorecard](https://api.securityscorecards.dev/projects/github.com/google/osv-scanner/badge)](https://securityscorecards.dev/viewer/?uri=github.com/google/osv-scanner)
|

---

### Release Notes

<details>
<summary>google/osv-scanner (google/osv-scanner)</summary>

###
[`v2.6.0`](https://redirect.github.com/google/osv-scanner/blob/HEAD/CHANGELOG.md#v260)

[Compare
Source](https://redirect.github.com/google/osv-scanner/compare/v2.5.1...v2.6.0)

##### Features:

- [Feature
#&#8203;2888](https://redirect.github.com/google/osv-scanner/pull/2888)
Publish multi-arch (`linux/arm64`) image for `osv-scanner-action`.
- [Feature
#&#8203;3066](https://redirect.github.com/google/osv-scanner/pull/3066)
Configure retry policy with exponential backoff for transient gRPC
errors in scalibr plugins.
- **Dependency scanning & lockfile improvements via `osv-scalibr`**:
- Extract Git repository URLs and support local OSV tag matching for
Git-based dependencies in JavaScript lockfiles (`package-lock.json`,
`yarn.lock`, `pnpm-lock.yaml`, `bun.lock`).
- Assign `pkg:git` PURL type to Git commit-pinned dependencies across JS
and Cargo lockfiles to avoid false positives against registry packages
([#&#8203;2863](https://redirect.github.com/google/osv-scanner/pull/2863)).
- Retain packages without a version or PURL in SPDX output
([google/osv-scalibr#2375](https://redirect.github.com/google/osv-scalibr/pull/2375))
and merge related packages based on lineage relationships.
- **New extractors and plugin support via `osv-scalibr`**:
- Many additional filetypes are supported. These are not enabled by
default yet, so if you need a particular new filetype, use
`--experimental-plugins` flag. See ["Supported Inventory
Types"](https://redirect.github.com/google/osv-scalibr/blob/3f6473abebb329f3e0dc7e9e0d9c91e0c6e51277/docs/supported_inventory_types.md)
for the extractor name.

##### Fixes:

- [Bug
#&#8203;3075](https://redirect.github.com/google/osv-scanner/pull/3075)
Ensure `results` property in JSON output is an empty array `[]` instead
of `null` when scanning with `--allow-no-lockfiles` and no lockfiles are
found.
- [Bug
#&#8203;3071](https://redirect.github.com/google/osv-scanner/pull/3071)
Preserve valid UTF-8 sequences when truncating multibyte text in
vertical output.
- [Bug
#&#8203;2919](https://redirect.github.com/google/osv-scanner/pull/2919)
Add filter to show packages with license violations but no
vulnerabilities in the HTML report.
- [Bug
#&#8203;3049](https://redirect.github.com/google/osv-scanner/pull/3049)
Keep filter dropdown checklist open when clicking options in the HTML
report.
- [Bug
#&#8203;3023](https://redirect.github.com/google/osv-scanner/pull/3023)
Guard against panic on empty or whitespace-only license expressions in
SPDX license evaluation.
- [Bug
#&#8203;3032](https://redirect.github.com/google/osv-scanner/pull/3032)
Bound recursion depth when parsing SPDX license expressions to prevent
stack overflow on deeply nested expressions.
- [Bug
#&#8203;3061](https://redirect.github.com/google/osv-scanner/pull/3061)
Remove purl caching in scan filtering to avoid dropping SBOM packages
without purls.
- [Bug
#&#8203;3063](https://redirect.github.com/google/osv-scanner/pull/3063)
Log plugin and enricher errors during container scans instead of failing
silently.
- [Bug
#&#8203;2977](https://redirect.github.com/google/osv-scanner/pull/2977)
Return an error instead of aborting the process (`log.Fatalf`) when an
`rlib` archive has no object file during Rust source analysis.
- [Bug
#&#8203;3083](https://redirect.github.com/google/osv-scanner/pull/3083)
Return a descriptive error from `DoContainerScan` when
`ScannerActions.Image` is empty instead of panicking.
- **Fixes via `osv-scalibr`**:
- Fix false-positive Go standard library matches for packages with
module paths ending in `/go` (e.g.
`pkg:golang/github.com/json-iterator/go`)
([#&#8203;3017](https://redirect.github.com/google/osv-scanner/issues/3017)).
- Secure guided remediation file operations with `os.Root` to prevent
path traversal attacks
([google/osv-scalibr#2363](https://redirect.github.com/google/osv-scalibr/pull/2363)).
- Prevent OOM and disk exhaustion issues with tar bombs during archive
extraction.
- Strip platform suffix from RubyGems versions in CycloneDX
([google/osv-scalibr#2313](https://redirect.github.com/google/osv-scalibr/pull/2313)).
- Ignore `.deps.json` files that don't have an object as their root in
`dotnet/depsjson` extractor
([google/osv-scalibr#2423](https://redirect.github.com/google/osv-scalibr/pull/2423)).

##### Misc:

- Update `osv-scalibr` to `v0.5.3-0.20260911142458-3090dbb7aaa2`
([#&#8203;3079](https://redirect.github.com/google/osv-scanner/pull/3079)).
- Update Go to v1.27 and `golangci-lint` to v2.13
([#&#8203;3046](https://redirect.github.com/google/osv-scanner/pull/3046)).
  - This now supports call analysis on go v1.27 projects.
- Update `google.golang.org/grpc` to v1.83.2
([#&#8203;3062](https://redirect.github.com/google/osv-scanner/pull/3062)).

</details>

---

### Configuration

📅 **Schedule**: (in timezone America/Los_Angeles)

- Branch creation
  - "before 6am"
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend Renovate
CLI](https://redirect.github.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC42MS4zIiwidXBkYXRlZEluVmVyIjoiNDQuNjEuMyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiYmluYXJ5LWRlcCIsInZlbmRvcmVkIl19-->

Co-authored-by: renokeeper[bot] <308156799+renokeeper[bot]@users.noreply.github.com>
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
osv-scanner 2.6.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>### Features:

- [Feature #2888](google/osv-scanner#2888) Publish multi-arch (`linux/arm64`) image for `osv-scanner-action`.
- [Feature #3066](google/osv-scanner#3066) Configure retry policy with exponential backoff for transient gRPC errors in scalibr plugins.
- **Dependency scanning & lockfile improvements via `osv-scalibr`**:
  - Extract Git repository URLs and support local OSV tag matching for Git-based dependencies in JavaScript lockfiles (`package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`, `bun.lock`).
  - Assign `pkg:git` PURL type to Git commit-pinned dependencies across JS and Cargo lockfiles to avoid false positives against registry packages ([#2863](google/osv-scanner#2863)).
  - Retain packages without a version or PURL in SPDX output ([google/osv-scalibr#2375](google/osv-scalibr#2375)) and merge related packages based on lineage relationships.
- **New extractors and plugin support via `osv-scalibr`**:
  - Many additional filetypes are supported. These are not enabled by default yet, so if you need a particular new filetype, use `--experimental-plugins` flag. See ["Supported Inventory Types"](https://github.com/google/osv-scalibr/blob/3f6473abebb329f3e0dc7e9e0d9c91e0c6e51277/docs/supported_inventory_types.md) for the extractor name.

### Fixes:

- [Bug #3075](google/osv-scanner#3075) Ensure `results` property in JSON output is an empty array `[]` instead of `null` when scanning with `--allow-no-lockfiles` and no lockfiles are found.
- [Bug #3071](google/osv-scanner#3071) Preserve valid UTF-8 sequences when truncating multibyte text in vertical output.
- [Bug #2919](google/osv-scanner#2919) Add filter to show packages with license violations but no vulnerabilities in the HTML report.
- [Bug #3049](google/osv-scanner#3049) Keep filter dropdown checklist open when clicking options in the HTML report.
- [Bug #3023](google/osv-scanner#3023) Guard against panic on empty or whitespace-only license expressions in SPDX license evaluation.
- [Bug #3032](google/osv-scanner#3032) Bound recursion depth when parsing SPDX license expressions to prevent stack overflow on deeply nested expressions.
- [Bug #3061](google/osv-scanner#3061) Remove purl caching in scan filtering to avoid dropping SBOM packages without purls.
- [Bug #3063](google/osv-scanner#3063) Log plugin and enricher errors during container scans instead of failing silently.
- [Bug #2977](google/osv-scanner#2977) Return an error instead of aborting the process (`log.Fatalf`) when an `rlib` archive has no object file during Rust source analysis.
- [Bug #3083](google/osv-scanner#3083) Return a descriptive error from `DoContainerScan` when `ScannerActions.Image` is empty instead of panicking.
- **Fixes via `osv-scalibr`**:
  - Fix false-positive Go standard library matches for packages with module paths ending in `/go` (e.g. `pkg:golang/github.com/json-iterator/go`) ([#3017](google/osv-scanner#3017)).
  - Secure guided remediation file operations with `os.Root` to prevent path traversal attacks ([google/osv-scalibr#2363](google/osv-scalibr#2363)).
  - Prevent OOM and disk exhaustion issues with tar bombs during archive extraction.
  - Strip platform suffix from RubyGems versions in CycloneDX ([google/osv-scalibr#2313](google/osv-scalibr#2313)).
  - Ignore `.deps.json` files that don't have an object as their root in `dotnet/depsjson` extractor ([google/osv-scalibr#2423](google/osv-scalibr#2423)).

### Misc:

- Update `osv-scalibr` to `v0.5.3-0.20260911142458-3090dbb7aaa2` ([#3079](google/osv-scanner#3079)).
- Update Go to v1.27 and `golangci-lint` to v2.13 ([#3046](google/osv-scanner#3046)).
  - This now supports call analysis on go v1.27 projects.
- Update `google.golang.org/grpc` to v1.83.2 ([#3062](google/osv-scanner#3062)).

## New Contributors
* @summerpan688 made their first contribution in google/osv-scanner#2919
* @BenkiNew made their first contribution in google/osv-scanner#3038
* @Amey-Thakur made their first contribution in google/osv-scanner#3032
* @sl4x0 made their first contribution in google/osv-scanner#3023
* @shubhransh-gupta made their first contribution in google/osv-scanner#3049
* @kobihikri made their first contribution in google/osv-scanner#2977
* @skialpine made their first contribution in google/osv-scanner#2888
* @keeltrace made their first contribution in google/osv-scanner#3071
* @Muszic made their first contribution in google/osv-scanner#3083
* @knQzx made their first contribution in google/osv-scalibr#2313
* @micrictor made their first contribution in google/osv-scalibr#2047
* @srossross made their first contribution in google/osv-scalibr#2375

**Full Changelog**: https://github.com/google/osv-scanner/compare/v2.5.1...v2.6.0</pre>
  <p>View the full release notes at <a href="https://github.com/google/osv-scanner/releases/tag/v2.6.0">https://github.com/google/osv-scanner/releases/tag/v2.6.0</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!20195
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants