Audits API security for mass assignment, missing rate limits, GraphQL/gRPC misconfig, REST hygiene gaps, API key mishandling, and WebSocket/SSE access-control defects across web frameworks.
Ships in Aegis Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Audit the HTTP-facing surface of the target repository for API-specific design and configuration failures that let a client exceed its intended authority: write fields the server never meant to expose, consume unbounded resources, enumerate internals through schema and documentation surfaces, skip transport or channel authentication, or ride privileged channels cross-origin. For every finding produce file:line evidence, a reproduction recipe (static-first), a severity with rationale, and a framework-correct fix.
| Class | Typical finding | Primary CWE |
|---|---|---|
| Mass assignment / over-posting | Client sets role, is_admin, price, user_id through request-body binding to ORM entities | CWE-915 |
| Rate limiting & anti-automation | Unthrottled auth/search/export endpoints, no pagination caps, no per-key quotas | CWE-770, CWE-799 |
| GraphQL configuration | Prod introspection, exposed playground/GraphiQL, no depth/complexity limits, batching abuse, field-suggestion leakage | CWE-200, CWE-400 |
| gRPC / protobuf | Public reflection service, plaintext h2c listeners reachable externally, missing per-RPC auth interceptors | CWE-306, CWE-200 |
| REST hygiene | _method override shadowing, state-changing GET, deprecated versions still live, unauthenticated OpenAPI docs, debug headers, CORS wildcard with credentials, content-type confusion entry points, leaky error envelopes | CWE-200, CWE-942 |
| API key management | Keys accepted in URLs, shared keys embedded in mobile/SDK builds, god-mode unscoped keys, no revocation flow | CWE-798 |
| WebSocket / SSE channels | Missing Origin validation at upgrade, handshake-only authentication, topics without per-user ACLs | CWE-346, CWE-862 |
_method override interplay; defer token analysis.Read-only access to the repository; no running instance is guaranteed. Treat dynamic reproduction as optional and permissible only against explicitly authorized environments. Static confirmation grounded in documented framework semantics is sufficient evidence for reporting.
Zero-background primer: the terms this module uses, one line each. Deeper plain-language explanations for every class live in the repository GUIDE.md glossary.
is_adminAn API handler composes four contracts the client sees only partially:
Most API findings are a mismatch between what developers modeled and what a framework auto-generated in one of these layers. Mass assignment lives in binding and serialization. Throttling, origin, and channel-auth findings live in transport and middleware. Disclosure findings live in the schema surface: OpenAPI files, GraphQL introspection, protobuf reflection.
Modern stacks optimize developer ergonomics: bind the whole request body to a model, hydrate entities from JSON, expose descriptors for tooling. Each convenience is a permissive default:
/openapi.json, gRPC reflection).Audit for an explicit opt-IN to safety (field allowlists, limiters, disabled introspection, auth interceptors), not merely the absence of an explicit opt-out. Assume permissive defaults until proven otherwise.
Every endpoint has a server-side cost and a client-side price. Search-with-joins, export, password-reset mailers, and SMS sends multiply cost; pagination caps and throttles are the meter. A missing meter converts one request into ten thousand automated requests: enumeration, brute force, scraping, financial drain. Judge each expensive endpoint by asking one question: what stops a script calling it 10,000 times?
One URL, thousands of reachable resolvers, client-shaped queries. Perimeter auth at /graphql protects nothing if resolvers skip object-level checks because "the schema is internal". The schema itself is a public map of your object graph; query depth is an attacker-chosen loop counter. Treat every resolver as an unauthenticated handler until middleware proves otherwise, and treat introspection, playgrounds, and field suggestions as documentation leaks.
Protobuf replaces JSON binding; reflection replaces Swagger; interceptors replace middleware. Ask the same questions: who can call which RPC (per-method auth metadata enforced by an interceptor, or nowhere?), what does an oversized or unknown-field-filled message do to memory and storage, and is the plaintext h2c port reachable from outside the cluster?
WebSocket and SSE connections are long-lived and multiplex actions over messages. Handshake-time authentication without per-message authorization means any connected socket inherits the session's powers for the connection lifetime. When the Origin check at upgrade is also absent, a malicious web page in a victim's browser opens that socket cross-origin and rides the victim's cookies.
ModelSerializer with permissive fields, Mongoose models passed straight to create()/findByIdAndUpdate(), Sequelize/Prisma create(req.body), Eloquent Model::create($request->all()), Rails Model.new(params) without permit, Spring @ModelAttribute bound onto a JPA entity, ASP.NET Core [FromBody] User user where User is a DbSet<> entity, Go json.NewDecoder(r.Body).Decode(&domainStruct) into a shared model.fields = "__all__", NestJS DTOs used with ValidationPipe() lacking whitelist: true, Laravel models missing $fillable (or $guarded = []), Pydantic models configured extra="allow".role, roles, is_admin, admin, permissions, price, amount, balance, discount, status, verified, email_verified, user_id, owner_id, account_id, tenant_id, created_at, password_hash, credits. For each candidate, trace whether any client-facing path binds it.Object.assign(entity, req.body), spread of req.body into update objects, Python setattr loops over payload keys, Ruby merge!(params), EF Core CurrentValues.SetValues(dto) onto entities, dict.update(payload).accepts_nested_attributes_for, writable nested DRF serializers, Mongoose subdocument arrays hydrated from the body.X-Forwarded-For is client-controlled (app.set('trust proxy', true)). Prefer user-id/API-key keys with IP fallback.SELECT ... LIMIT, no .all()/.find({})/FindAll returning unbounded sets, export endpoints streaming entire tables in one request.include: [...all], populate(), select_related chains), search joining across large tables, PDF/report generation.@nestjs/graphql, graphql-yoga, strawberry-graphql, graphene, gqlgen, graphql-go). Determine production values of introspection and landing-page/playground flags, not just their existence in code.id/uuid argument that fetch-and-return objects without ownership or tenant checks, especially near comments like "internal schema".[{"query":"..."},...]) enabling many operations per request? Is AutomaticPersistedQuery used with a registered-operation allowlist, or does it accept arbitrary hashes?errors[].extensions.NewServer()/h2c versus TLS; correlate listening ports with Dockerfile EXPOSE, Kubernetes manifests, and load-balancer config to judge external reachability.MaxRecvMsgSize (not math.MaxInt64), use of google.protobuf.Any with type-url-driven dispatch, unknown-field handling on persistence paths, enum validation before storage._method form/query parameters and X-HTTP-Method-Override middleware; confirm overridden verbs are restricted to an allowlist and CSRF-protected where session-authenticated.delete, update, create, reset, send, confirm, approve)./vN prefixes mounted simultaneously; deprecated versions still receiving traffic; security middleware (authz guards, limiters) wired only onto the newest router while /v1 runs bare./swagger, /swagger-ui.html, /api-docs, /openapi.json, /graphql with HTML Accept, redoc pages, drf-yasg, springdoc actuator mappings; confirm each is auth-gated in production wiring. Also read the spec content for internal-only hosts/endpoints described publicly.X-Powered-By, X-AspNet-Version, Symfony X-Debug-Token plus reachable /_profiler, Server banners, Access-Control-Expose-Headers listing internals.app.use(...) ordering; find groups (/internal, /webhooks, legacy /v1) that skip auth or rate-limit middlewares the modern groups apply.text/plain that bypass CSRF checks keyed on content type, GET handlers parsing bodies.renderer_classes, ASP.NET output formatters, Rails responders) exposing richer serializations than the default JSON view (for example ?format=xml dumping relations).api_key, access_token, token) versus headers (Authorization, X-API-Key). Flag URL transport: URLs land in proxy logs, browser history, and referrer headers.verifyClient in ws, cors option for socket.io, SignalR AllowedOrigins, CheckOrigin, OriginValidator).socket.on('action', ...) handlers mutating data using only handshake-derived identity plus client-supplied IDs.socket.join(req.body.room)).text/event-stream endpoints; verify auth on the stream request itself and on Last-Event-ID replay semantics (replay must not leak other tenants' events).| Stack | Binding/serializer files | Route/middleware files | Notes |
|---|---|---|---|
| Express/Fastify | handlers co-located with routes | app.js, server.ts, routes/*.js, Fastify schema: keys | Fastify JSON-schema additionalProperties:false changes binding posture; check each route schema |
| NestJS | *.dto.ts, entities/*.entity.ts | main.ts (global pipes/guards), *.controller.ts, app.module.ts | Global vs controller-level ValidationPipe; guard order |
| Django REST Framework | serializers.py, models.py | urls.py, views.py, settings.py REST_FRAMEWORK block | Default throttle classes live in settings |
| FastAPI/Flask-RESTful | Pydantic schemas schemas.py | main.py, api/*.py, Flask app = Flask(...) decorator chains | Pydantic extra config decides unknown-field behavior |
| Spring MVC/WebFlux | entity classes, projection DTOs, @ControllerAdvice | @SpringBootApplication main class, WebSecurityConfigurerAdapter/SecurityFilterChain beans, controllers | springdoc.* properties gate docs exposure |
| ASP.NET Core Web API | Models/, DTOs/ | Startup.cs/Program.cs, Controllers/*.cs | Middleware order in pipeline; Swashbuckle UseSwaggerUI env gating |
| Laravel/Lumen | app/Http/Requests/*, app/Models/* ($fillable) | routes/api.php, app/Http/Kernel.php ($middleware, $middlewareGroups) | throttle: middleware alias presence per route group |
| Rails API mode | app/models/*, app/serializers/* | config/routes.rb, config/application.rb, Rack::Attack initializer | ActionController::Base.allow_forgery_protection irrelevant in API mode; strong params in controllers |
| Go chi/gin/echo | handler files binding structs | router setup in main.go/cmd/*/main.go, middleware registration | No auto-binding magic; risk is decoding into shared domain structs |
| GraphQL (apollo/yoga/strawberry/graphene) | typeDefs, resolvers.*, schema files | server bootstrap file (apollo-server constructor, yoga config, strawberry extensions=[...]) | Validation rules configured only here |
| gRPC | *.proto, generated stubs ignored | server setup (grpc.NewServer(...), Python grpc.server(...), Java ServerBuilder) | Interceptors and reflection registered here |
settings.py: REST_FRAMEWORK dict (throttles, renderers, parsers), DEBUG, middleware list..env, config/*.yaml, application.properties/yml, appsettings.json: introspection flags, swagger enablement, rate-limit numbers, trust-proxy settings.Dockerfile, docker-compose.yml, k8s/: which ports (including plaintext gRPC) are published externally.nginx.conf, Envoy configs): platform-layer rate limiting that may satisfy throttling findings before flagging code.Start from route tables to enumerate the full endpoint inventory, then walk ingestion points for binding posture, then bootstrap/config files for global flags (pipes, limiters, introspection), then per-endpoint for missing controls. This ordering prevents mistaking one protected route group for an overall protected service.
All regexes run under ripgrep (rg) and the Rust regex crate: no lookarounds, no backreferences. Run from the repository root; triage hits manually before reporting.
fields\s*=\s*["']__all__["']
DRF serializer exposing every model column, including is_admin, password_hash.
\$request->all\(\)
Laravel/Lumen raw request array; check every hit for flow into create()/update()/fill().
->(create|update|fill|firstOrCreate|updateOrCreate)\(\$request->all\(\)\)
Direct Eloquent over-posting sink.
\.new\(params\[|\.create\(params\[|\.update\(params\[
Rails models built from unfiltered params; confirm .permit(...) exists upstream in the same action.
(Object\.assign|merge|extend)\(\s*[A-Za-z_$][\w$.]*\s*,\s*req\.body
Express/Fastify arbitrary-key merge onto a persisted object.
\.\.\.req\.body
Spread of client body into update payloads or constructor options.
\.(create|findByIdAndUpdate|findOneAndUpdate|updateOne|bulkWrite)\(\s*req\.body\b
Mongoose write sinks consuming the whole body.
ValidationPipe\(\)
NestJS pipe with default options: unknown properties pass through untouched.
@ModelAttribute|setAllowedFields|ignoreUnknownFields
Spring data-binding surface and its (rare) safety valves; flag @ModelAttribute bound to entity classes.
FromBody\]\s+[A-Za-z_][A-Za-z0-9_]*\s+\w+
ASP.NET Core body-bound parameters; diff the bound type name against DbSet<...> declarations to spot entity binding.
extra\s*[=:]\s*["'](allow|ignore)["']?
Pydantic posture: allow accepts and stores extras; plain ignore drops them (safe for writes).
setattr\s*\(\s*[a-z_]+\s*,\s*(k|key|field|attr|name)\s*,|merge!\(|SetValues\(|\.update\(payload\)|\.update\(data\)
Dynamic-key PATCH merge sinks across Python/Ruby/.NET/JS.
Inventory limiter presence first, then diff against your endpoint list:
(?i)(rate.?limit|throttle|rack.?attack|slowapi|flask_limiter|django_ratelimit|addratelimiter|ratelimiting|express-rate-limit|nestjs/throttler)
TooManyRequests|StatusTooManyRequests|HttpStatusCode\.TooManyRequests
Unbounded collection sinks:
\.all\(\)|\.find\(\s*\{\s*\}\s*\)|findAll\(\)|FindAll\(\)|SELECT\s+\*\s+FROM
Pagination parameters expected on list routes (their absence on a collection route is the finding):
[?&](page|per_page|pageSize|limit|offset|cursor|after|before)=
Proxy-trust foot-guns for IP-keyed limiters:
trust proxy|trustProxy|X-Forwarded-For
introspection\s*:|GRAPHQL_INTROSPECTION|disableIntrospection|DisableIntrospection|introspectionEnabled
graphiql|playground|landingPage|LandingPage|GraphiQL
Depth/complexity controls (presence is good; absence near a GraphQL bootstrap is the finding):
depthLimit|max_depth|maxDepth|QueryDepthLimiter|complexity|ComplexityLimit|costAnalysis|validationRules
Batching/persisted-query machinery:
PersistedQuery|persistedQueries|APQ|shouldPersistedQuery|batching
reflection\.Register|enable_server_reflection|ProtoReflectionService|RegisterReflectionService
Plaintext listeners:
insecure\.NewCredentials|InsecureServerCredentials|WithTransportCredentials\(insecure|h2c
Auth interceptor presence (absence near server construction is the finding):
UnaryInterceptor|StreamInterceptor|ServerInterceptors|ServerInterceptor|AddUnaryInterceptors|AddStreamInterceptors
Message-size posture:
MaxRecvMsgSize|MaxReceiveMessageSize|max_receive_message_length
Method override machinery:
_method|methodOverride|MethodOverride|X-HTTP-Method-Override|HttpMethodOverride
State changes on GET (Express-style; repeat the scan manually over Rails/Django/Flask route tables):
\.(get|GET)\(\s*["'][^"']*(delete|remove|destroy|update|edit|create|reset|send|confirm|approve)
Version sprawl:
/api/v[0-9]|["']/v[0-9]+/
Docs exposure:
swagger-ui|swagger\.json|openapi\.json|api-docs|UseSwaggerUI|drf_yasg|drf-spectacular|flask_swagger_ui|springdoc
Debug/internal header emission:
X-Powered-By|x-aspnet-version|x-debug-token|_profiler|exposeHeaders|Access-Control-Expose-Headers
CORS wildcard and origin reflection:
Access-Control-Allow-Origin["']?\s*[,:]\s*["']?\*
origin\s*:\s*true|callback\(null,\s*req\.headers\.origin|SetIsOriginAllowed\(|AllowCredentials\(\)|credentials\s*:\s*true
Content-type confusion entry points (payload craft -> DESER module):
xml-bodyparser|lxml\.etree|etree\.fromstring|fromstring\(|JAXBContext|JacksonXml|XmlSerializer|application/xml
Error-envelope leakage:
err\.stack|error\.stack|traceback\.format_exc|printStackTrace|DEBUG\s*=\s*True|includeErrorDetails|DetailedErrors|includeStacktrace
Key accepted from URL/query (log-exposed transport):
request\.args\.get\(["'](api_key|apikey|token)["']\)|query\.Get\("api_key"\)|params\[:(api_key|token)\]|Request\.Query\[["']api_key
Hardcoded credential formats (well-known public prefixes):
AKIA[0-9A-Z]{16}|AIza[0-9A-Za-z_\-]{35}|sk_live_[0-9a-zA-Z]{16,}|ghp_[0-9A-Za-z]{36}|xox[baprs]-[0-9A-Za-z\-]{10,}
Scoping enforcement markers (presence is good):
scopes?\s*[=:]|hasScope|scope_required|check_scopes|permissions\.includes
Upgrade handling and origin validation:
WebSocketServer|io\.on\(["']connection|handleUpgrade|verifyClient|CheckOrigin|AllowedOrigins|OriginValidator|allowed_origins|origins
Per-message action handlers needing per-message authz:
socket\.on\(|conn\.on\(|OnConnected|receive\(|async_receive
Room/topic joins to ACL-check:
socket\.join\(|join_room|groups\.add|AddToGroupAsync|channels\.subscribe
SSE surfaces:
text/event-stream|EventSource|Last-Event-ID
Mass assignment bodies (POST/PUT/PATCH against registration, profile, order endpoints):
{"email":"[email protected]","password":"Str0ng!passphrase","is_admin":true}
{"username":"a","price":0,"user_id":2,"role":"admin"}
{"nickname":"x","tenant_id":1,"balance":999999,"email_verified":true}
PATCH merge probe (arbitrary keys into a partial update):
{"role":"admin","permissions":["*"],"status":"active"}
GraphQL probes:
{"query":"{__schema{types{name}}}"} — a JSON body containing "types" with a list of type names confirms introspection is enabled.{"query":"{__typename}"} — cheap liveness check for the GraphQL endpoint.{"query":"{users{usrnme}}"} — an error containing "Did you mean" leaks schema names.user -> friends -> friends -> friends ...; optionally amplified with duplicate aliases at each level. Confirm absence of depth/complexity limits statically before considering any dynamic test.[{"query":"{__typename}"},{"query":"{__typename}"}] — two answers in one response means operation batching is enabled.Pagination-absence probes:
?page=999999&limit=all
?limit=1000000
?offset=0&count=-1
?perPage=99999999
A dump-one-shot endpoint returns full data (not a 400/clamp) for these.
_method override examples:
POST /users/1/delete route registered for GET only
form body: _method=DELETE&_token=<csrf> Rails/Laravel form override
header: X-HTTP-Method-Override: PUT sent against POST /api/items/1
query: /api/items/1?_method=DELETE query-string variant
WebSocket cross-origin handshake probe:
curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" \
-H "Sec-WebSocket-Version: 13" -H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" \
-H "Origin: https://evil.example" https://host/ws
HTTP/1.1 101 Switching Protocols in response to a foreign Origin means upgrade-origin validation is absent.
Treat every client-supplied key-value pair as tainted at the transport boundary and follow it to a persistence sink. The taint of interest for mass assignment is the KEY NAME, not only the value: an attacker controls which attributes get written, not just what they contain.
| Language/Stack | Sources (client-controlled) | Sinks (persistence) |
|---|---|---|
| Node/Express/Fastify | req.body, req.query, req.params, Fastify parsed body | Model.create(), findByIdAndUpdate(), Object.assign(entity, ...), Knex update(payload), Prisma create(data) |
| NestJS | DTO parameter decorated @Body(), raw request.body in guards | repository .save(partialEntity), TypeORM preload()/merge() |
| Python DRF | request.data, serializer input | serializer.save(), Model.objects.create(**validated_data) |
| Python Flask/FastAPI | request.get_json(), Pydantic model fields (model_dump()) | db.session.add(obj), SQLAlchemy update(values) |
| Ruby Rails | params hash | Model.new(params), update(params), assign_attributes, merge! |
| PHP Laravel | $request->all(), $request->input() | ::create($array), ->fill($array), ->forceFill() |
| Java Spring | form/query binding onto annotated parameters, @RequestBody DTOs | JPA repositories .save(entity), setData(...) |
| C# ASP.NET | [FromBody] models, TryUpdateModelAsync | EF Core _context.Add(), CurrentValues.SetValues() |
| Go | json.NewDecoder(r.Body).Decode(&v), gin c.ShouldBindJSON(&v) | GORM .Create(v), .Updates(map), sqlx insert built from struct fields |
| GraphQL | resolver (root, args, ctx), nested input objects | same ORM sinks as host language |
permit, fields = [...], whitelist:true, $fillable, projection DTOs, pick() helpers). Any other transformation (validation, defaults, mapping libraries) does NOT break it unless it constructs a fresh object with named fields.id-like argument is its own source-to-sink path; check ownership predicates inside the resolver or its data-loader.// VULNERABLE - spread preserves attacker keys
const user = await User.create({ ...req.body });
// FIXED - explicit pick
const { email, password, nickname } = req.body;
const user = await User.create({ email, password, nickname });
# VULNERABLE - dynamic kwargs
User.objects.create(**request.data)
# FIXED - named fields
User.objects.create(email=request.data["email"], nickname=request.data.get("nickname", ""))
Confirm statically first; run dynamic steps only against environments you are explicitly authorized to test. Counts stay modest on purpose.
curl -s -X POST https://host/api/register -H 'Content-Type: application/json' \
-d '{"email":"[email protected]","password":"Str0ng!passphrase","is_admin":true}'
GET /api/admin/users).GET /api/me before and after a PATCH carrying "role":"admin", or simply confirm acceptance of the unknown key plus code-level sink — sufficient for reporting.curl -s -X PATCH https://host/api/users/me -H 'Content-Type: application/json' \
-H "Authorization: Bearer $TOKEN" -d '{"role":"admin","tenant_id":1}'
Expected observable: 200 OK echoing back the injected fields in the response body.
for i in $(seq 1 20); do
curl -s -o /dev/null -w "%{http_code}\n" -X POST https://host/api/login \
-H 'Content-Type: application/json' -d '{"email":"[email protected]","password":"wrong"}'
done | sort | uniq -c
200/401 responses and zero 429/403 throttles. A single 429 indicates a limiter exists; check its keying and scope next.curl -s "https://host/api/users?page=999999&limit=all" | head -c 400
curl -s "https://host/api/users" | wc -c
Expected observable: full data payload returned (not 400, not clamped to a max page size), and response size grows with table contents.
curl -s https://host/graphql -H 'Content-Type: application/json' \
-d '{"query":"{__schema{types{name}}}"}'
Expected observable: JSON containing a types array listing schema type names (Query, Mutation, custom types). An error like "GraphQL introspection is disabled" is the negative case; record the control.
curl -s https://host/graphql -H 'Accept: text/html' | grep -io 'graphiql\|playground'
Expected observable: HTML landing page markers (GraphiQL, Playground, ApolloServerPluginLandingPage output). Absence (JSON error instead of HTML) is the negative case.
curl -s https://host/graphql -H 'Content-Type: application/json' \
-d '{"query":"{users{usrnme}}"}'
Expected observable: errors[0].message containing "Did you mean ...?" and real field names.
grpcurl -plaintext host:50051 list
Expected observable: service list dumped without credentials. Connection refused/TLS required indicates plaintext posture findings separately.
curl -s -X POST "https://host/api/items/1" -H 'Content-Type: application/x-www-form-urlencoded' \
--data '_method=DELETE' -b "session=$SESSION"
Expected observable: item deleted via a POST-only route. Confirm statically which override middlewares are mounted and whether override verbs are allowlisted and CSRF-checked.
Probe in order: GET /swagger-ui.html, /swagger/index.html, /swagger/v1/swagger.json, /api-docs, /openapi.json, /docs, /graphql (HTML Accept). Expected observable: interactive docs UI HTML or raw spec JSON returned unauthenticated. Cross-check spec contents for internal hosts/endpoints.
Run the handshake probe from the Payload Cheat Sheet with Origin: https://evil.example. Expected observable for absence: 101 Switching Protocols. Then, if authorized, send an action message unauthenticated; success proves per-message authz is missing.
Static: locate query-string key acceptance. Dynamic corroboration: call the endpoint with ?api_key=..., then inspect access-log configuration (nginx $request_uri logging is default-on) — keys land wherever logs go.
| Framework | Risk marker | Correct pattern |
|---|---|---|
| Django REST Framework | fields = "__all__" | explicit fields = ("email", "nickname"); mark computed columns read_only=True |
| NestJS | ValidationPipe() bare | new ValidationPipe({ whitelist: true, forbidNonWhitelisted: true }) |
| Spring MVC | @ModelAttribute onto entity | projection DTO per use case; @InitBinder setAllowedFields; keep Jackson unknown-property failure on (spring.jackson.deserialization.fail-on-unknown-properties=true) |
| Rails API | Model.new(params) | params.require(:user).permit(:email, :nickname) |
| Laravel | $request->all() into Eloquent | strict $fillable on models; consume FormRequest validated() only; never forceFill from client input |
| FastAPI | Pydantic posture decision | writes: model_config = ConfigDict(extra="forbid") for request models; reads may stay ignore |
| ASP.NET Core | [FromBody] Entity | separate DTOs + explicit AutoMapper profiles; avoid SetValues from unfiltered DTOs |
| Express/Fastify | spreads of req.body | destructure named fields, or Fastify route schema with additionalProperties: false so ajv strips extras |
| Go | decode into domain structs | dedicated request structs containing only client-writable fields |
// VULNERABLE
app.useGlobalPipes(new ValidationPipe());
// FIXED
app.useGlobalPipes(new ValidationPipe({ whitelist: true, forbidNonWhitelisted: true }));
# VULNERABLE (DRF)
class UserSerializer(ModelSerializer):
class Meta:
model = User
fields = "__all__"
# FIXED
class UserSerializer(ModelSerializer):
class Meta:
model = User
fields = ("email", "nickname")
read_only_fields = ("is_admin", "role", "user_id")
# FIXED (Rails)
def user_params
params.require(:user).permit(:email, :nickname)
end
// FIXED (Laravel)
class User extends Model {
protected $fillable = ['email', 'nickname'];
}
// controller consumes only validated data
$user = User::create($request->validated());
// FIXED (ASP.NET Core) - bind a DTO, not the entity
public record UpdateUserDto(string Nickname); // no Role, no TenantId
Decision guidance for Pydantic extra: choose forbid when the endpoint is client-writable (turns over-posting into a 422), accept ignore where payloads are server-internal; never allow.
Gateway-layer option: where an API gateway fronts the services, JSON-schema request validation at the gateway (per-route body schemas that strip/reject unknown properties) is an acceptable compensating layer while code-level field allowlists are rolled out.
Apply limiters at the platform layer AND in code (defense in depth). Token-bucket defaults that work widely: auth endpoints 5 requests/min keyed by username+IP; general API 60-120 requests/min per user or API key with short burst allowance; export/search 10 requests/min. Key by user-id/API-key first, IP second.
// Express - express-rate-limit
const { rateLimit } = require("express-rate-limit");
const loginLimiter = rateLimit({ windowMs: 60_000, max: 5, standardHeaders: true });
app.use("/api/login", loginLimiter);
// NestJS - @nestjs/throttler
@Module({ imports: [ThrottlerModule.forRoot([{ ttl: 60_000, limit: 100 }])] })
// plus @Throttle({ default: { limit: 5, ttl: 60_000 } }) on auth controllers
# Flask - slowapi / DRF settings
REST_FRAMEWORK = {
"DEFAULT_THROTTLE_CLASSES": ["rest_framework.throttling.ScopedRateThrottle"],
"DEFAULT_THROTTLE_RATES": {"login": "5/min", "search": "30/min", "export": "10/hour"},
}
# Rails - Rack::Attack
Rack::Attack.throttle("login/ip", limit: 5, period: 60) { |req| req.ip if req.path == "/api/login" }
// ASP.NET Core (.NET 7+) built-in rate limiting
builder.Services.AddRateLimiter(o => o.AddFixedWindowLimiter("auth", w => {
w.Window = TimeSpan.FromMinutes(1); w.PermitLimit = 5;
}));
Server-side pagination caps regardless of client hints:
// FIXED - clamp before querying
const limit = Math.min(parseInt(req.query.limit ?? "20", 10), 100);
const page = Math.max(parseInt(req.query.page ?? "1", 10), 1);
Add captcha/proof-of-work or equivalent friction to signup, voting, and redemption flows; enforce per-API-key quotas at the gateway or in middleware backed by a plan-tier table.
introspection: false in production; omit landing-page plugin (ApolloServerPluginLandingPageGraphQLPlayground) or add ApolloServerPluginUsageReporting-style prod gating; disable field suggestions via formatError/masked errors.graphql-depth-limit inside validationRules: [depthLimit(10)]; cost analysis (graphql-cost-analysis) or Apollo estimateComplexity; cap aliases where the library supports it.plugins: [useDepthLimit({ maxDepth: 10 })], maskedErrors enabled by default — keep it on.strawberry.extensions.QueryDepthLimiter(max_depth=10) in the schema extensions list.// VULNERABLE
const server = new ApolloServer({ typeDefs, resolvers });
// FIXED
const server = new ApolloServer({
typeDefs, resolvers,
introspection: false,
validationRules: [depthLimit(10)],
});
// VULNERABLE
lis, _ := net.Listen("tcp", ":50051")
s := grpc.NewServer() // plaintext
// FIXED
creds, _ := credentials.NewServerTLSFromFile("cert.pem", "key.pem")
s := grpc.NewServer(grpc.Creds(creds))
// FIXED - unary interceptor validating metadata
func AuthInterceptor(ctx context.Context, req interface{},
info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
md, _ := metadata.FromIncomingContext(ctx)
if len(md.Get("authorization")) == 0 { return nil, status.Error(codes.Unauthenticated, "missing token") }
return handler(ctx, req)
}
grpc.NewServer(grpc.UnaryInterceptor(AuthInterceptor), grpc.ChainStreamInterceptor(StreamAuth))
Python: build with interceptors=[...] (e.g. grpc-interceptor). Java: ServerBuilder.addService(...) paired with ServerInterceptors.intercept(service, authInterceptor) for every service.
MaxRecvMsgSize, Java maxInboundMessageSize), validate enums, avoid google.protobuf.Any for security-relevant dispatch, and strip unknown fields before persistence paths that echo stored messages back.Serve API docs behind authentication or restrict to internal networks; split external and internal specs so internal endpoints never appear in the public file. Framework switches: springdoc.api-docs.enabled=false (or gated profile) in prod, DRF drf-spectacular/drf-yasg views wrapped in IsAdminUser permission classes, Swashbuckle UseSwaggerUI() inside if (app.Environment.IsDevelopment()), swagger-ui-express mounted after auth middleware. Strip X-Powered-By/framework banners (app.disable("x-powered-by"), Program.cs header removal), and route Symfony profiler away from production.
Validate Origin against an allowlist during upgrade; authenticate per message for actions; authorize topic/room joins per user; re-check authorization on every event delivery.
// VULNERABLE (ws)
const wss = new WebSocket.Server({ port: 8080 }); // no origin check
// FIXED
const wss = new WebSocket.Server({
port: 8080,
verifyClient: (info) => allowlist.includes(new URL(info.origin).host),
});
wss.on("connection", (ws) => {
ws.on("message", (raw) => {
const msg = JSON.parse(raw);
if (!canAct(ws.user, msg.action, msg.targetId)) return; // per-message authz
});
});
// socket.io - origin allowlist + handshake token
new Server({ cors: { origin: ["https://app.example.com"], credentials: true } })
.use((socket, next) => next(jwt.verify(socket.handshake.auth.token) ? undefined : new Error("unauthorized")));
SignalR: AllowedOrigins("https://app.example.com"). Django Channels: OriginValidator around the ASGI application plus scope-level permission checks per consumer. SSE: authenticate the stream request, and validate that Last-Event-ID replay stays within the requester's own tenant.
Transport keys in headers only (X-API-Key, Authorization: Bearer); reject query-string key parameters. Scope every key to a permission set enforced at request time; issue separate keys per environment and per integration; implement revocation (status flag checked per request) and rotation endpoints; store hashes of keys, never plaintext. Mobile/SDK builds ship only public client identifiers — anything secret-capable belongs behind a backend-for-frontend.
{"email":"[email protected]","password":"x","is_admin":true}, THEN the server responds 400/422 naming the rejected property (forbid mode) or persists the object without the extra field (strip mode); a follow-up read shows no is_admin.?limit=1000000 arrives, THEN the response contains at most the clamped page size and reports the cap.{"query":"{__schema{types{name}}}"} is sent, THEN the endpoint returns an error and leaks zero type names; WHEN a registered client sends a persisted query hash, THEN execution still succeeds.Unauthenticated for every service including streams./openapi.json or /swagger-ui.html, THEN it receives 401/403/redirect.Origin: https://evil.example, THEN the server rejects the upgrade (no 101).# CI contract test: unknown fields must never reach persistence
def test_register_rejects_unknown_fields(api_client):
payload = {"email": "[email protected]", "password": "Str0ng!passphrase", "is_admin": True}
r = api_client.post("/api/register", json=payload)
assert r.status_code in (400, 422) or "is_admin" not in r.json()
login = api_client.post("/api/login", json={"email": "[email protected]", "password": "Str0ng!passphrase"})
me = api_client.get("/api/me", headers=auth(login))
assert me.json().get("is_admin") is not True
def test_login_throttled():
codes = [post_login(wrong_password=True).status_code for _ in range(20)]
assert 429 in codes
def test_list_endpoint_capped():
body = get_json("/api/users?limit=1000000")
assert len(body["items"]) <= 100
rg -n 'fields\s*=\s*["'"'"']__all__["'"'"']' --type py
rg -n '\$request->all\(\)'
rg -n 'ValidationPipe\(\)'
rg -n 'introspection\s*:\s*true|GRAPHQL_INTROSPECTION'
rg -n 'reflection\.Register|enable_server_reflection|ProtoReflectionService'
rg -n 'insecure\.NewCredentials|WithTransportCredentials\(insecure|h2c'
rg -n '_method|X-HTTP-Method-Override'
rg -n '[\?&]api[_-]?key='
Expected post-fix state: each query returns only reviewed-and-accepted occurrences (dev-gated, allowlisted, or documented exceptions).
| Finding | Baseline severity | CVSS v3.1 vector | CWE |
|---|---|---|---|
Mass assignment writing is_admin/role (privilege escalation) | Critical | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H | CWE-915 |
Mass assignment on non-security fields (price, user_id) | High | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:H/A:L | CWE-915 |
| Throttling absence alone (no lockout bypass demonstrated) | Low-Medium, context-driven | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:L | CWE-770, CWE-799 |
| Pagination absence / dump-one-shot on sensitive table | Medium-High by data class | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N | CWE-770 |
| Introspection + playground + docs exposure | Low-Medium information disclosure | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N | CWE-200 |
| Field-suggestion leakage / stack-trace error envelopes | Low-Medium | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N | CWE-200 |
| CORS wildcard with credentials on API | High when session-bearing | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N | CWE-942 |
| API key transported in URL | High | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N | CWE-798 |
| Shared embedded SDK key granting account-wide access | High | assess reachability from shipped binary | CWE-798 |
| WebSocket hijack (no origin check, no per-message auth) | High | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:L | CWE-346, CWE-862 |
| gRPC plaintext + missing per-RPC auth on business RPCs | High if externally reachable | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N | CWE-306 |
| Deprecated API version live without current fixes | Medium inventory risk | CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:N | CWE-200 |
Raise severity one band when the vulnerable surface is internet-reachable AND unauthenticated. Lower one band when exploitation requires an internal network position (gRPC ports), an authenticated low-privilege context that already grants equivalent powers, or when compensating platform controls (gateway limiter, WAF) demonstrably cover the gap — cite the control file in the finding either way. Rate-limit findings stay Low-Medium unless chained with credential stuffing, enumeration, or financial flows, which push them to High.
fields = "__all__" on admin-only or read-only viewsets: verify the route's permission classes before flagging; internal-only serializers with IsAdminUser are acceptable.whitelist where the handler destructures named fields before persistence: binding is permissive but the sink is safe; trace the sink, not just the pipe.limit_req, Envoy rate-limit filters, Cloudflare rules satisfy the control; check infra configs and note the compensating control instead of reporting absence.IsAdmin, Role).extra=ignore: unknown fields are dropped, so FastAPI endpoints are rarely over-postable unless extra="allow" is set or raw dicts flow to sinks._method/override middleware in Rails/Laravel: built-in implementations restrict overrides to safe verbs and integrate CSRF protection; flag custom or unrestricted override handling, not the framework feature itself.LIMIT defaults even when query params are absent: read the actual query construction./v1 routes proxy through the identical handler set and current middleware: shared handlers mean no patch gap; report only divergent code paths.Project home: https://owasp.org/www-project-api-security/
| OWASP item | This module's coverage |
|---|---|
| API1:2023 Broken Object Level Authorization | GraphQL resolver object-level gaps; WebSocket topics/actions; IDOR-enabled sinks (primary coverage in AUTHZ module) |
| API2:2023 Broken Authentication | Platform throttling of auth endpoints; key transport/scoping (lockout specifics in AUTHN module) |
| API3:2023 Broken Object Property Level Authorization | Mass assignment / over-posting class end-to-end |
| API4:2023 Unrestricted Resource Consumption | Rate limiting, pagination caps, depth/complexity limits, message-size ceilings |
| API5:2023 Broken Function Level Authorization | Route-group middleware parity; hidden-endpoint exposure via docs/introspection |
| API6:2023 Unrestricted Access to Sensitive Business Flows | Anti-automation friction on signup/redemption/voting flows |
| API7:2023 Server Side Request Forgery | Out of scope here — covered by DESER/SSRF module |
| API8:2023 Security Misconfiguration | Introspection/playground/docs/debug headers/CORS/content-type confusion/gRPC reflection |
| API9:2023 Improper Inventory Management | Version sprawl, stale specs, deprecated versions live |
| API10:2023 Unsafe Consumption of APIs | Partially covered (key scoping toward third parties); full coverage deferred |
What SKILL.md sets; muted values are Claude Code's defaults
40 skills in this plugin
/aegis-api-token-securityAudits the full lifecycle of bearer/API tokens protecting an internet-exposed HTTP API — minting entropy and format, hash-only server storage, transport rules, scoping, expiry and rotation, revocation, per-key rate limits, and log hygiene — with read-only evidence commands and hardened reference implementations./aegis-authn-sessionDetect authentication and session management failures across login, password storage, password reset, MFA, session lifecycle, JWT/OAuth/API-key handling, remember-me, and session storage./aegis-authz-access-controlDetects broken function-level and object-level authorization (BFLA/BOLA), vertical and horizontal privilege escalation, tenant-isolation failures, path/header bypasses, and unsafe delegation across mainstream web frameworks and APIs./aegis:aegis-api-securityfrom Aegis Skills
npx claudepluginhub as-foss/aegis-skills --plugin aegisOther plugins' skills for the same job