Skip to content

fix(security): separate runtime state from HTTP input - #4

Merged
RentnerKev merged 1 commit into
mainfrom
codex/fix-codeql-request-state
Aug 31, 2026
Merged

RentnerKev merged 1 commit into
mainfrom
codex/fix-codeql-request-state

Conversation

@RentnerKev

@RentnerKev RentnerKev commented Aug 31, 2026 •

Copy link
Copy Markdown
Member

CodeQL's Axum model treats every route-handler parameter as remote input. Our handlers accepted State<AppState>, so the configured runtime directory and CA bundle were propagated to filesystem sinks even though request data never selected those paths.

This change captures application-owned state when each route is registered and leaves only actual HTTP extractors as handler parameters. Existing canonical-path, direct-child, UUID, and certificate-ID validation remains active. Obsolete CodeQL suppression comments and duplicate checks are removed.

Security regression coverage now verifies that URL-encoded traversal attempts are rejected across host and certificate routes and that separately constructed routers retain isolated runtime state.

Validation:

  • cargo fmt -- --check
  • cargo test --all-targets --all-features (67 passed)
  • cargo clippy --all-targets --all-features -- -D warnings

Summary by CodeRabbit

  • Bug Fixes

    • Strengthened file and resource path validation to reject encoded path traversal attempts and null-byte identifiers.
    • Improved protection for certificate and proxy-host routes against unsafe resource access.
    • Ensured separately configured server instances retain isolated runtime state and settings.
  • Tests

    • Added coverage for invalid resource identifiers and isolated server configurations.

@coderabbitai

coderabbitai Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: d3e6f19e-655a-48cd-9e68-4e12f0d34932

📥 Commits

Reviewing files that changed from the base of the PR and between 917aff2 and 4655c86.

📒 Files selected for processing (4)
  • controller/src/runtime/state.rs
  • controller/src/server/handlers.rs
  • controller/src/server/mod.rs
  • controller/src/tests/server.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The controller now uses shared safe-path validation and passes AppState explicitly through route closures. New tests cover invalid resource identifiers and isolated state between routers.

Changes

Controller runtime and routing

Layer / File(s) Summary
Shared safe path validation
controller/src/runtime/state.rs
SafeDir and file-opening helpers use shared validation. Canonicalization, metadata checks, and symlink checks remain in place.
Explicit application state routing
controller/src/server/handlers.rs, controller/src/server/mod.rs
Handlers accept AppState directly. Route closures capture cloned state instead of using Axum’s State extractor.
Route validation and state isolation tests
controller/src/tests/server.rs
Tests reject traversal, absolute-path, Windows-path, and null-byte identifiers. Tests also verify isolated router configuration state.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 4655c

The change separates application-owned runtime state from HTTP input while retaining path validation and regression coverage; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main security change: separating runtime state from HTTP input in route handlers.
Description check ✅ Passed The description explains what changed, why it changed, the security impact, regression coverage, and validation commands. It does not include the template headings for Type of change or Checklist, but…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains what changed, why it changed, the security impact, regression coverage, and validation commands. It does not include the template headings for Type of change or Checklist, but the core required information is present.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-codeql-request-state

Comment @coderabbitai help to get the list of available commands.

@RentnerKev
RentnerKev merged commit 4655c86 into main Aug 31, 2026
15 checks passed
@RentnerKev
RentnerKev deleted the codex/fix-codeql-request-state branch August 31, 2026 21:21
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