Gate /debug endpoints out of production
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 30/100
- Issue-Typ
- Feature
- Klarheit
- Muss geklärt werden
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- fastapi, python, typescript
- Bereich
- api, authentication, backend, security
Rechercherichtung
Beginne in src/smartem_backend/api_server.py bei den Definitionen der Debug-Routen und prüfe, wie die Konfiguration behandelt wird; lies anschließend tests/smartem_backend/test_debug_sessions.py und die in der Issue erwähnten Referenzen zum generierten Client. Die Arbeit ist abgeschlossen, wenn ein abgestimmter Ansatz die Debug-Endpunkte wie vorgesehen einschränkt, entfernt oder ausschließt und die betroffenen Tests sowie die generierten Ausgaben aktualisiert sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Narrowed from the original "Address API vulnerability". The vulnerability as originally
described - debug endpoints reachable with no authentication at all - has been fixed. What
remains is a smaller, concrete hardening task, retained here so it is not lost.
What changed since this was filed
verify_token is now attached to the FastAPI application itself
(src/smartem_backend/api_server.py), so it applies to every route. EXEMPT_PATHS in
src/smartem_backend/auth.py covers only /health, /status, /openapi.json, /docs and
/redoc - no debug paths. Reaching any /debug/* endpoint now requires a valid Keycloak token.
What is still outstanding
1. The endpoints are not gated by environment. The original recommendation had two parts:
authenticate them, and conditionally disable them in production. The first is done; the second
was never implemented. There is no configuration flag or environment check governing them.
All eight remain registered, including write operations:
GET /debug/agent-connectionsGET /debug/sessionsGET /debug/connection-statsGET /debug/session/{session_id}/instructionsPOST /debug/sessions/create-managedPOST /debug/sessions/createPOST /debug/session/{session_id}/create-instructionDELETE /debug/sessions/{session_id}/close
2. They have no production consumer. The only references anywhere are
tests/smartem_backend/test_debug_sessions.py (added under #258) and the frontend's
generated MSW mock handlers - and those exist only because the endpoints appear in the
OpenAPI spec, not because the front end calls them.
3. They propagate into the published spec. Because they are in the OpenAPI document, they
flow into the generated frontend client and mocks, and into any other consumer generated from
that spec.
4. Authentication is not authorisation. Token claims are validated but are not used to
scope access, so a valid token is not currently constrained to its own session's data. That is
a broader piece of work and is deliberately not in scope here - it was recorded on #85 when
that issue was closed.
Options
Not picking one up front; they trade off differently:
- Environment gating - register the debug routes only when a configuration flag is set.
Keeps them available in development, removes them entirely from production. include_in_schema=False- keeps the endpoints but drops them from the OpenAPI document,
so they stop propagating into the generated client and mocks. Addresses (3) but not (1).- Removal - they have no production consumer. The only cost is
test_debug_sessions.py,
which was written for #258 and would go with them.
Gating and schema exclusion are complementary rather than alternatives.
Code references
src/smartem_backend/api_server.py- debug route definitions, and the app-level
dependencies=[Depends(verify_token)]src/smartem_backend/auth.py-EXEMPT_PATHStests/smartem_backend/test_debug_sessions.py- sole test consumer
- Vorherrschende Sprache
- TypeScript
- Sterne
- 0
- Forks
- 0
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus DiamondLightSource/smartem-devtools
-
security
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
-
Dependency DashboardOffen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 15/100
-
research security
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
-
devops research smartem-agent
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
-
Make Claude's project knowledge portable: private memory/transcripts, derived public AGENTS.mdOffenenhancement smartem-devtools:claude
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 45/100
Alle Issues in DiamondLightSource/smartem-devtools
Ähnliche Issues
-
area: frontend priority: normal
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
formbricks/formbricks#9918 ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
thecodacus/pithagoras#364 ·
Maintainer antworten meist innerhalb von 1 Tag
-
TestAutonomousStop_ReportsObservedState fails under host load: 1s wall-clock ceiling vs 250ms cycleOffentype:bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
nightgauge/nightgauge#2909 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 1 Tag