π‘οΈ Sentinel: [HIGH] Fix Unprotected UI Routes#217
π‘οΈ Sentinel: [HIGH] Fix Unprotected UI Routes#217EffortlessSteven wants to merge 2 commits intomainfrom
Conversation
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.
|
π 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Summary of ChangesHello @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
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
| // 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), | ||
| }; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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_guardmiddleware to theui_routerincrates/app-http/src/lib.rs - Added integration test
ui_auth_security.rsto 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/tasksroute is also a UI endpoint that displays sensitive governance data (task board with task information) and should be protected by theplatform_auth_guardmiddleware 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.
|
Warning Rate limit exceeded
β How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. π Files selected for processing (3)
β¨ Finishing Touchesπ§ͺ Generate unit tests (beta)
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. Comment |
Test Results283 testsβββ245 β
ββ11m 5s β±οΈ Results for commit 5158a67. |
π‘οΈ 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 whenPLATFORM_AUTH_MODEwas enabled.π― Impact: Information disclosure of internal governance documentation and configuration.
π§ Fix: Applied
platform_auth_guardmiddleware to theui_routerincrates/app-http/src/lib.rs.β Verification: Added
crates/app-http/tests/ui_auth_security.rswhich 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