Skip to content

fix(dotnet): add forbidden-arg checker — block MSBuild Custom*Targets / runsettings RCE - #128

Merged
thehoff merged 3 commits into
developfrom
fix/dotnet-arg-checker
May 22, 2026
Merged

thehoff merged 3 commits into
developfrom
fix/dotnet-arg-checker

Conversation

@thehoff

@thehoff thehoff commented May 22, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes E2E review SEC-C1 (CRITICAL). dotnet was the one ecosystem with env-strip but no argv deny-list checker — MSBuild exposes RCE-grade CLI flags env-stripping doesn't touch.

check_forbidden_dotnet_args (in src/core/utils.rs, following the check_forbidden_go_args #111 pattern) now rejects, wired into all 3 dotnet run paths, failing closed:

  • MSBuild property assignment to CustomBefore*/CustomAfter* targets/props (injects an attacker .targets with <Exec> → RCE) — via -p://p:/--property:/-property:.
  • dotnet test --runsettings/-s (RunSettings can load attacker assemblies).

Review found and closed two bypasses in the first cut:

  • semicolon-batched form -p:Configuration=Release;CustomBeforeMicrosoftCommonTargets=evil — now every ;-pair is checked.
  • case-insensitive flag prefixes (-P:, --PROPERTY:) — MSBuild folds case; checker now does too.
  • @response-file args rejected (they expand to arbitrary MSBuild flags).

Test Plan

  • 160 dotnet tests pass; deny + positive-control + bypass-regression tests
  • CI full suite

Part of the 2026-05-22 E2E review remediation.

🤖 Generated with Claude Code

thehoff and others added 3 commits May 22, 2026 09:51
Third independent review pass — security core, command filters,
analytics/discovery, runtime-data mining. 5 top-tier findings (2 P0
operational, 3 security CRITICAL), 13 important, plus data-grounded
feature ideas. Measured blended savings 53.4%; 33 startup crashes in 7 days.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… / runsettings RCE (SEC-C1)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@thehoff
thehoff merged commit 46cb72a into develop May 22, 2026
4 checks passed
@thehoff
thehoff deleted the fix/dotnet-arg-checker branch May 22, 2026 04:35
noogalabs pushed a commit to noogalabs/contextcrawler that referenced this pull request Jun 4, 2026
* feat(gain): add per-project token savings with -p flag

Record project_path (cwd) in tracking database and add filtered query
methods. `rtk gain -p` shows savings scoped to the current project
directory instead of global aggregates.

- tracking.rs: Add project_path column with auto-migration, index,
  and filtered variants for all query methods (summary, daily, weekly,
  monthly, recent)
- gain.rs: Add resolve_project_scope(), shorten_path(), scope-aware
  header, pass project filter to all queries and exports
- main.rs: Add --project/-p flag to Gain command

Backward-compatible: existing rows get empty project_path, unfiltered
queries delegate to filtered(None) which returns all data.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(tracking): use GLOB instead of LIKE for project path filtering

Address reviewer feedback on PR thehoff#128:

1. Replace SQL LIKE with GLOB in all project-scoped queries to prevent
   `_` and `%` characters in path names from being interpreted as
   wildcards (e.g., `my_project` matching `myXproject`). GLOB uses `*`
   for wildcard matching which is safer for file system paths.

2. Guard the startup `UPDATE commands SET project_path = ''` migration
   with an `EXISTS` check so it only runs when NULL rows actually exist,
   avoiding a no-op UPDATE on every startup after the first migration.

3. Add `DEFAULT ''` to the ALTER TABLE migration so new installs never
   create NULL project_path values.

4. Add 3 new unit tests for project_filter_params GLOB behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant