fix(security): require authentication for profiler endpoints#366
fix(security): require authentication for profiler endpoints#366nihalnihalani wants to merge 2 commits intorocketride-org:developfrom
Conversation
All 5 profiler endpoints (/profile, /profile/start, /profile/stop, /profile/status, /profile/report) were registered with public=True, bypassing the AuthMiddleware entirely. This allows unauthenticated users to start/stop profiling and read performance reports that expose internal function names, call counts, and timing data. Remove public=True from all profiler route registrations so they require authentication like other protected endpoints. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughRemoved Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/ai/src/ai/modules/profiler/__init__.py`:
- Around line 155-156: The docs and status listing incorrectly state the
profiler endpoints use PUT while the actual routes use POST; update the usage
header text and the get_status() returned endpoint list to show '/profile/start'
and '/profile/stop' as POST methods and ensure any docstring or header
mentioning start_profiling and stop_profiling reflects POST instead of PUT so
consumers see the correct HTTP method.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: a30f3b43-1510-437c-86c1-c10c34fea3dc
📒 Files selected for processing (1)
packages/ai/src/ai/modules/profiler/__init__.py
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
PR #362 has the same changes (almost), plus unit tests. |
|
Hi @nihalnihalani, thanks for the security fix here! It looks like @heatxsink opened #362 for the same profiler auth bypass, and that PR also includes HTML escaping for the We'd love to have your eyes on other open issues — there are still several security findings that need attention! |
Aligns documentation with actual route registration (POST, not PUT). Incorporates fix from rocketride-org#366.
|
Closing this PR in favor of #362 |
Summary
public=Truefrom all 5 profiler endpoint registrations to enforce authenticationBug Description
File:
packages/ai/src/ai/modules/profiler/__init__.py(lines 152–156)Severity: High — Information Disclosure + Denial of Service
All 5 profiler endpoints are registered with
public=True, which tells theAuthMiddlewareto skip authentication:This means any unauthenticated user can:
1. Information Disclosure
GET /profile/reportreturns a full profiling report containing:GET /profile/statusreveals session history and runtime statisticsGET /profileserves an interactive HTML dashboard with all dataThis is valuable reconnaissance data — an attacker learns internal function names, hot paths, and performance characteristics before launching targeted attacks.
2. Denial of Service
POST /profile/startenables cProfile, which adds measurable CPU overhead to every function call in the Python processPOST /profile/stopcan interrupt legitimate profiling sessionsAttack Scenario
Root Cause
The profiler module was likely registered as public during development for easy debugging and the
public=Trueflags were never removed before release.Fix
Remove
public=Truefrom all 5 route registrations. Without this flag, theAuthMiddleware(defined inpackages/ai/src/ai/web/middleware.py) requires authentication for these endpoints — the same protection applied to all other non-public routes.No new code needed — just removing the bypass flag.
Verification
ruff checkpassesruff formatpasses/use,/task, etc.)/redocand/openapi.jsonremain as intentionally public endpointsReferences
#frontier-tower-hackathon
Summary by CodeRabbit