Starlette 1.6.0

Last reviewed Sep 20, 2026

Export as PDF

Prompt Details

Prompt Composition

2prompts
  1. Python 3155 lines · 3.8K tokens
  2. Starlette 1.6.083 lines · 4.2K tokens
Total238 lines · 8K tokens

CWE Coverage

  • 20
  • 22
  • 23
  • 36
  • 59
  • 78
  • 79
  • 89
  • 95
  • 113
  • 117
  • 203
  • 208
  • 209
  • 214
  • 250
  • 287
  • 295
  • 306
  • 319
  • 328
  • 338
  • 347
  • 352
  • 367
  • 379
  • 409
  • 416
  • 426
  • 427
  • 434
  • 470
  • 488
  • 502
  • 524
  • 532
  • 552
  • 601
  • 611
  • 613
  • 614
  • 639
  • 674
  • 732
  • 770
  • 772
  • 776
  • 807
  • 829
  • 862
  • 916
  • 918
  • 942
  • 1004
  • 1104
  • 1275
  • 1333
  • 1395

Prompt Preview

Apply the Python 3 prompt first. Target Starlette 1.6.0 on a maintained Python 3.10–3.14 runtime. These rules address Starlette's ASGI boundaries and APIs; retain the baseline controls for database queries, outbound requests, dependencies, and secrets.

Routing, middleware, and proxy trust

  • Declare Route, Mount, and Host entries in trusted code, put specific paths before catch-all routes, and specify permitted HTTP methods. A route permitting GET also accepts HEAD; HTTPEndpoint can dispatch HEAD to get(). Apply the same authorization and keep both methods free of state changes.
  • Cover every protected mount, host, static subtree, fallback, and WebSocketRoute with authorization. Middleware attached to one route or mount does not protect siblings; a bare Router does not supply the Starlette application's default error middleware.
  • Review the actual stack: ServerErrorMiddleware, optional application RequestBodyLimitMiddleware, user middleware in list order, then ExceptionMiddleware and routing. Place SessionMiddleware before AuthenticationMiddleware when the backend reads sessions. Return denial responses directly from application middleware instead of relying on endpoint HTTPException handling.
  • Use pure ASGI middleware for controls that must cover both http and websocket scopes, and pass lifespan through. BaseHTTPMiddleware handles HTTP only and prevents endpoint ContextVar changes from propagating back to outer middleware; do not base authorization or audit identity on that propagation.
  • Keep connection-specific identity,