Skip to content

πŸ›‘οΈ Sentinel: [HIGH] Fix Unprotected UI Routes#217

Draft
EffortlessSteven wants to merge 2 commits intomainfrom
sentinel/protect-ui-routes-15929363388092540886
Draft

πŸ›‘οΈ Sentinel: [HIGH] Fix Unprotected UI Routes#217
EffortlessSteven wants to merge 2 commits intomainfrom
sentinel/protect-ui-routes-15929363388092540886

Conversation

@EffortlessSteven
Copy link
Member

πŸ›‘οΈ Sentinel: [HIGH] Fix Unprotected UI Routes

🚨 Severity: HIGH
πŸ’‘ Vulnerability: The Platform UI routes (/, /ui/*) were not protected by the platform authentication middleware. This allowed unauthenticated users to view sensitive governance data (specs, tasks, config summary) even when PLATFORM_AUTH_MODE was enabled.
🎯 Impact: Information disclosure of internal governance documentation and configuration.
πŸ”§ Fix: Applied platform_auth_guard middleware to the ui_router in crates/app-http/src/lib.rs.
βœ… Verification: Added crates/app-http/tests/ui_auth_security.rs which confirms that unauthenticated requests now receive a 401 Unauthorized response, while authenticated requests succeed.


PR created automatically by Jules for task 15929363388092540886 started by @EffortlessSteven

This change applies the `platform_auth_guard` middleware to the UI routes (`/`, `/ui/*`) in `crates/app-http/src/lib.rs`. Previously, these routes were accessible without authentication even when `PLATFORM_AUTH_MODE` was set to `Basic` or `Jwt`, exposing sensitive governance data.

A new regression test `crates/app-http/tests/ui_auth_security.rs` verifies that:
- Unauthenticated requests to `/` return 401 Unauthorized.
- Authenticated requests (with `x-platform-token`) return 200 OK.

This fixes a high-severity information disclosure vulnerability.
Copilot AI review requested due to automatic review settings February 25, 2026 12:11
@google-labs-jules
Copy link

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@gemini-code-assist
Copy link

Summary of Changes

Hello @EffortlessSteven, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical security vulnerability by implementing proper authentication middleware for the Platform UI routes. Previously, these routes were exposed, allowing unauthorized access to sensitive internal data. The changes ensure that all UI endpoints are now secured, preventing information disclosure, and are accompanied by new tests to validate the fix.

Highlights

  • Security Vulnerability Fix: Addressed a high-severity vulnerability where Platform UI routes ("/", "/ui/*") were not protected by authentication middleware, potentially exposing sensitive governance data to unauthenticated users. The platform_auth_guard middleware has been applied to these routes.
  • Enhanced Test Coverage: Introduced a new integration test (crates/app-http/tests/ui_auth_security.rs) to explicitly verify that UI routes correctly return a 401 Unauthorized response for unauthenticated requests and a 200 OK for authenticated ones.
Changelog
  • .jules/sentinel.md
    • Documented a new high-severity vulnerability regarding unprotected UI routes, including learning points and prevention strategies.
  • crates/app-http/src/lib.rs
    • Applied the platform_auth_guard middleware to the ui_router to enforce authentication on UI routes.
    • Updated the auth_state cloning to ensure correct middleware application.
  • crates/app-http/tests/ui_auth_security.rs
    • Added a new test file to verify that UI routes are properly protected by authentication when enabled, asserting 401 for unauthenticated access and 200 for authenticated access.
Activity
  • The pull request was created automatically by Jules for task 15929363388092540886, initiated by @EffortlessSteven.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with πŸ‘ and πŸ‘Ž on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly addresses a high-severity vulnerability by applying authentication middleware to the UI routes. The fix is straightforward and effective. The addition of an integration test (ui_auth_security.rs) is excellent, as it properly verifies that unauthenticated access is now blocked while authenticated access is permitted. The suggestion to simplify the new test file to make it more focused on what it's testing remains valid.

Comment on lines 24 to 53
// Configure Basic Auth
let mut settings = HashMap::new();
settings.insert("platform.auth_mode".to_string(), serde_yaml::Value::String("basic".to_string()));

let mut secrets = HashMap::new();
secrets.insert("platform.auth_token".to_string(), "test-token".to_string());

let config = ValidatedConfig {
env: Some("test".to_string()),
http_port: 8080,
settings,
secrets,
};

// Construct app state manually to bypass load_valid_config
let platform_auth = PlatformAuthConfig {
mode: PlatformAuthMode::Basic,
token: Some("test-token".to_string()),
jwt_secret: None,
};

let app_state = AppState {
governance_repo: repo,
workspace_root: workspace_root.clone(),
config: Some(config),
platform_auth,
cors_config: app_http::CorsConfig::default(),
security_headers_config: app_http::SecurityHeadersConfig::default(),
repo_context: gov_model::RepoContext::new(&workspace_root),
};

Choose a reason for hiding this comment

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

medium

The test setup for config, settings, and secrets is unnecessary as this test only depends on platform_auth being correctly configured in the AppState. The UI route handlers can gracefully handle a None config. Simplifying the AppState construction will make the test more focused and easier to maintain.

    // Construct app state manually to bypass load_valid_config
    let platform_auth = PlatformAuthConfig {
        mode: PlatformAuthMode::Basic,
        token: Some("test-token".to_string()),
        jwt_secret: None,
    };

    let app_state = AppState {
        governance_repo: repo,
        workspace_root: workspace_root.clone(),
        config: None,
        platform_auth,
        cors_config: app_http::CorsConfig::default(),
        security_headers_config: app_http::SecurityHeadersConfig::default(),
        repo_context: gov_model::RepoContext::new(&workspace_root),
    };

Run `cargo fmt` to fix formatting violations in `crates/app-http/tests/ui_auth_security.rs` that caused CI failure.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a high-severity security vulnerability where Platform UI routes were not protected by authentication middleware, allowing unauthenticated users to view sensitive governance data even when PLATFORM_AUTH_MODE was enabled.

Changes:

  • Applied platform_auth_guard middleware to the ui_router in crates/app-http/src/lib.rs
  • Added integration test ui_auth_security.rs to verify unauthenticated requests receive 401 and authenticated requests succeed
  • Documented the vulnerability and prevention strategy in .jules/sentinel.md

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
crates/app-http/src/lib.rs Applied platform_auth_guard middleware to ui_router and cloned auth_state for reuse
crates/app-http/tests/ui_auth_security.rs Added integration test verifying UI routes return 401 without auth and 200 with valid token
.jules/sentinel.md Documented the vulnerability, learning about Axum middleware behavior, and prevention strategy
Comments suppressed due to low confidence (2)

crates/app-http/src/lib.rs:416

  • The /ui/tasks route is also a UI endpoint that displays sensitive governance data (task board with task information) and should be protected by the platform_auth_guard middleware when authentication is enabled, similar to the other UI routes. Currently, this route is merged without authentication protection, creating the same vulnerability that this PR aims to fix for the other UI routes.
    let tasks_router =
        Router::new().with_state(app_state.clone()).route("/ui/tasks", get(tasks_ui::<AppState>));

crates/app-http/tests/ui_auth_security.rs:78

  • The test should verify authentication protection for all UI routes including /ui/tasks, /ui/graph, /ui/flows, and /ui/coverage, not just the root / route. This ensures comprehensive test coverage for the security fix.
#[tokio::test]
async fn test_ui_dashboard_protected_when_auth_enabled() {
    let workspace_root = test_workspace_root();
    let repo = Arc::new(FsGovernanceRepository::new(workspace_root.clone()));

    // Configure Basic Auth
    let mut settings = HashMap::new();
    settings
        .insert("platform.auth_mode".to_string(), serde_yaml::Value::String("basic".to_string()));

    let mut secrets = HashMap::new();
    secrets.insert("platform.auth_token".to_string(), "test-token".to_string());

    let config =
        ValidatedConfig { env: Some("test".to_string()), http_port: 8080, settings, secrets };

    // Construct app state manually to bypass load_valid_config
    let platform_auth = PlatformAuthConfig {
        mode: PlatformAuthMode::Basic,
        token: Some("test-token".to_string()),
        jwt_secret: None,
    };

    let app_state = AppState {
        governance_repo: repo,
        workspace_root: workspace_root.clone(),
        config: Some(config),
        platform_auth,
        cors_config: app_http::CorsConfig::default(),
        security_headers_config: app_http::SecurityHeadersConfig::default(),
        repo_context: gov_model::RepoContext::new(&workspace_root),
    };

    let app = app_http::app_with_state(app_state);

    // 1. Request dashboard without auth header -> 401 Unauthorized
    let response = app
        .clone()
        .oneshot(Request::builder().uri("/").body(Body::empty()).unwrap())
        .await
        .unwrap();

    assert_eq!(response.status(), StatusCode::UNAUTHORIZED, "UI should be protected");

    // 2. Request dashboard with valid x-platform-token -> 200 OK
    let response = app
        .oneshot(
            Request::builder()
                .uri("/")
                .header("x-platform-token", "test-token")
                .body(Body::empty())
                .unwrap(),
        )
        .await
        .unwrap();

    assert_eq!(response.status(), StatusCode::OK, "UI should be accessible with valid token");
}


πŸ’‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coderabbitai
Copy link

coderabbitai bot commented Feb 25, 2026

Warning

Rate limit exceeded

@EffortlessSteven has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 0 minutes and 8 seconds before requesting another review.

βŒ› How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 90fd4d1 and 5158a67.

πŸ“’ Files selected for processing (3)
  • .jules/sentinel.md
  • crates/app-http/src/lib.rs
  • crates/app-http/tests/ui_auth_security.rs
✨ Finishing Touches
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sentinel/protect-ui-routes-15929363388092540886

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

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

@github-actions
Copy link

Test Results

283 tests   245 βœ…β€ƒβ€ƒ11m 5s ⏱️
 25 suites   38 πŸ’€
  1 files      0 ❌

Results for commit 5158a67.

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