Detects application-layer DoS and resource-exhaustion flaws (ReDoS, unbounded parsing, quadratic algorithms, pagination abuse, event-loop blocking, cache/log fill, cost amplification) via static inspection and bounded live probes.
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.
Primary CWE mappings used throughout this module:
| CWE | Name | Used for |
|---|---|---|
| CWE-400 | Uncontrolled Resource Consumption | General missing-limits DoS findings |
| CWE-1333 | Inefficient Regular Expression Complexity | ReDoS findings |
| CWE-409 | Improper Handling of Highly Compressed Data (Data Amplification) | Zip/decompression bomb findings |
Secondary CWEs referenced inline where they fit better than the three above: CWE-405 (Asymmetric Resource Consumption / Amplification), CWE-407 (Inefficient Algorithmic Complexity), CWE-674 (Uncontrolled Recursion), CWE-770 (Allocation of Resources Without Limits or Throttling), CWE-776 (Improper Restriction of Recursive Entity References in DTDs, i.e. XML entity expansion), CWE-789 (Memory Allocation with Excessive Size Value). All of these are verified CWE identifiers; do not invent additional ones.
OWASP Top 10 2021 mapping: A05:2021 – Security Misconfiguration covers missing body-size limits, unsafe parser defaults, and absent timeouts. Findings rooted in algorithm/design choices (quadratic logic, unbounded GraphQL fanout) additionally map to A04:2021 – Insecure Design; state both when relevant.
Audit the application layer only. You are looking for code and configuration that lets ONE small request — or a handful of requests — consume disproportionate CPU, memory, disk, connection slots, or money.
In scope:
LIMIT; export/report endpoints materializing entire datasets in memory.Out of scope (note as CONFIG cross-ref only, do not audit deeply):
client_body_timeout, proxy_read_timeout, LB idle timeout). Record what you see in proxy config; do not attempt exploitation.Objectives for the executor:
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.
Everything in this module is an amplification attack: the attacker sends N bytes and forces the server to spend M units of work, where M/N is the weapon. Your job is to find the largest achievable M/N per endpoint.
Four resource pools can be drained, and each has characteristic signatures:
| Pool | Attack classes | Typical signature in code |
|---|---|---|
| CPU | ReDoS, quadratic loops, sort/comparator abuse, hash collisions, transcodes | Backtracking regex shapes; nested loops over request arrays; string concatenation in loops; sync crypto/image work |
| Memory | Deep JSON/XML, decompression bombs, load-whole-file imports, base64 decode bombs, export-to-memory | Parsers with no depth cap; extractall(); .toArray(); Model.objects.all() serialized wholesale; bytearray(n) sized from input |
| Disk / handles | Log flood, temp-file spillover, session-store spam, cache growth | Error handlers logging req.body; caches with no TTL/maxmemory; upload spool directories never pruned |
| Money | Bill-bomb via paid APIs | SMS/email senders called synchronously per request; webhook-triggered video transcodes with no quota |
Two structural questions classify every finding:
limit=-1, limit=99999999, compressed input expanding past the byte cap, proxy limit skipped by direct-to-origin access).Language/engine reality check you MUST internalize before judging regexes: not every (a+)+ shaped pattern is exploitable. RE2-family engines (Go regexp, Rust regex) guarantee linear time and cannot catastrophically backtrack. Everything else in mainstream use (V8/JavaScript, Python re, PCRE/PHP, .NET, Java java.util.regex, Ruby Onigmo) backtracks and CAN blow up. Judge the pattern AGAINST THE ENGINE THAT RUNS IT.
Carry this closing question into every candidate finding before you spend any probe budget: what is the most expensive thing ONE request can force this application to do?
regexp, Rust regex) for backtracking findings — they are linear-time by construction; instead flag any place a USER-SUPPLIED PATTERN ITSELF is compiled (new RegExp(req.query.q), re.compile(user_input)): hostile patterns are their own DoS sink regardless of engine.(a+)+$, (a|a)*$, (.*a){20}, nested quantifiers like (\d+)*, overlapping alternations like (a|ab)+, quantified groups over dot-star.if len(s) > 256: reject). A tight length cap converts even an evil pattern into a bounded-cost operation — record its exact bound and confirm it precedes matching.net/http has NO body cap at all).req.file.buffer, MemoryStream, byte[] b = ...ReadAllBytes(), file.read()) before validation?JSON.parse on arbitrary bodies, Python json.loads of multi-MB payloads) plus endpoints accepting arrays-of-arrays. Confirm framework-level field-count caps exist (Django DATA_UPLOAD_MAX_NUMBER_FIELDS, PHP max_input_vars, Rack query-parser limits) or note their absence.Buffer.from(x,'base64'), base64.b64decode, FromBase64String) where decoded size is ~4/3 the attacker-chosen input length and the result is buffered wholesale or fed to an image decoder.for item in body.items: wrapping another scan; .contains/.includes inside a loop = O(n^2)).string += or result = result + x inside loops instead of StringBuilder/System.Text.StringBuilder.String.hashCode is h = 31*h + c; historically exploited as "HashDoS" against PHP and Java containers via crafted POST parameter floods). Modern mitigations: randomized seeds (Python/Ruby SipHash), parameter-count caps (PHP max_input_vars default 1000, Tomcat POST param limits). Audit CUSTOM caches/maps keyed by user strings without entry caps.select_related/prefetch_related; Rails association calls in each blocks without includes; JPA FetchType.LAZY walked in a for-loop; SQLAlchemy lazy loads in serializers). Each extra list element adds a DB round-trip — an attacker sending 10k-element arrays forces 10k queries.limit/page/offset reach SQL/ORM: is there a DEFAULT when omitted, and a hard UPPER CLAMP? limit = min(params[:per_page] || 20, 100) is safe; LIMIT #{params['limit']} with no clamp is not.?limit=99999999&page=1, page_size=2147483647, negative limits (limit=-1 sometimes bypasses clamps entirely), non-numeric garbage causing full scans via exception fallback..all() piped into a serializer, find({}).toArray() then res.json(...), Model.objects.all() wrapped in JsonResponse. These are memory bombs proportional to table size.COUNT(*) over unbounded tables and cursor-less "load more" designs that re-scan from offset 0 repeatedly.crypto.pbkdf2Sync (iteration counts above ~100k pin a core per request), bcrypt.hashSync/compareSync, child_process.execSync/spawnSync, fs.readFileSync on uploads, zlib.inflateSync on client data, JSON.parse of multi-MB strings, synchronous image ops (jimp-style). One blocked event loop stalls ALL concurrent requests.UV_THREADPOOL_SIZE); many concurrent crypto.pbkdf2/fs/zlib calls queue behind it. Verify pool sizing rationale exists if heavy pooled work is present.server.requestTimeout (default 300000 ms) and headersTimeout (60000 ms); Go http.Server needs explicit ReadTimeout, ReadHeaderTimeout, WriteTimeout, IdleTimeout — zero values mean forever.pg Pool default max 10, HikariCP maximumPoolSize default 10. Slow endpoints (the other findings in this module) holding these slots turn CPU DoS into availability failure of the whole app.maxmemory (default 0 = unlimited) and maxmemory-policy (default noeviction)./var/lib/php/sessions, rows in a session table, entries in Redis)? Session-creation spam is a classic fill vector (cross-ref authn-session.md).logger.error("...", exc_info=True, extra={"body": req.body}), console.error(req.body)): repeated huge bodies fill disk. Verify log rotation exists (logrotate units, Docker json-file max-size/max-file, Winston daily rotate).| Stack | Config location | Key(s) | Default |
|---|---|---|---|
| Node/Express | app bootstrap (app.use(express.json(...))) | express.json({ limit }), express.urlencoded({ limit }) | 100kb per parser |
| Node/multer | multer init | multer({ limits: { fileSize, files } }) | none unless set (streamed, but uncapped) |
| Django | settings.py | DATA_UPLOAD_MAX_MEMORY_SIZE, FILE_UPLOAD_MAX_MEMORY_SIZE, DATA_UPLOAD_MAX_NUMBER_FIELDS | 2621440 bytes, 2621440 bytes, 1000 fields |
| Flask | app config | MAX_CONTENT_LENGTH | unset = unlimited |
| FastAPI/Starlette | ASGI app/middleware | no built-in body cap | unlimited — must add middleware |
| Spring Boot (servlet) | application.properties/.yml | spring.servlet.multipart.max-file-size, spring.servlet.multipart.max-request-size | 1MB / 10MB |
| Spring WebFlux | same files | spring.codec.max-in-memory-size | 256KB |
| ASP.NET Core | Program.cs/Startup.cs Kestrel config; attributes | ConfigureKestrel(o => o.Limits.MaxRequestBodySize), [RequestSizeLimit], [RequestFormLimits(MultipartBodyLengthLimit=...)] | 30,000,000 bytes (~28.6 MiB); multipart form part limit 128 MB |
| ASP.NET (IIS hosting) | web.config | <requestLimits maxAllowedContentLength> | 30,000,000 bytes |
| PHP | php.ini | post_max_size, upload_max_filesize, memory_limit, max_input_vars | commonly 8M / 2M / 128M / 1000 (verify deployed ini) |
| Ruby/Rails | Rack layer | Rack::QueryParser param count/depth guards; ActiveStorage blob size validations | Rack enforces param limits; verify gem version is current |
| Go | handler code | http.MaxBytesReader(w, r.Body, n); http.Server{ReadTimeout, ReadHeaderTimeout, WriteTimeout, IdleTimeout} | NO body cap; timeouts zero = never |
| nginx (front) | nginx.conf / site blocks | client_max_body_size (0 disables!), client_body_timeout, proxy_read_timeout, proxy_connect_timeout | 1m |
Treat nginx/front-proxy caps as the OUTER boundary only: direct-to-origin access (internal DNS, port 8080, container networking) bypasses them. The application-level cap is what you audit hardest.
| Target | Look in |
|---|---|
| Regex call sites | validator/util directories; route files; middleware chains; Pattern.compile/new RegExp(/re.compile(/preg_/Regexp.new occurrences |
| Import/export features | controllers named import/export/bulk/csv/report; admin routers; background job classes |
| XML parsing | SOAP endpoints, SAML consumers, RSS/feed fetchers, config-upload features |
| Archive handling | upload processors, backup-restore features, static-asset pipelines |
| Cache/session stores | Redis clients and their config files (redis.conf: maxmemory, maxmemory-policy), session store initializers |
| Log plumbing | logger setup files, global error handlers, logrotate.d units, Docker/K8s log driver options |
| Job queues | worker entrypoints, queue definitions (BullMQ/Celery/Sidekiq/Hangfire/asynq) |
| Proxy tier | nginx.conf, Caddyfile, HAProxy cfg, ingress annotations — CONFIG cross-ref for timeouts/body size/rate limits |
The next section gives you the executable signatures to run over these locations.
| Pattern | Language(s) at risk | Risk | Fix |
|---|---|---|---|
(a+)+$, ^(\d+)*$ | V8/JavaScript, Python re, PCRE/PHP, .NET, Java, Ruby | Exponential backtracking when trailing chars prevent a match (CWE-1333) | Rewrite with atomic/possessive constructs or migrate engine (safe-alternatives table below) |
| `(a | a)*$, (a | ab)+$` | same five engines |
(.*a){20} | same five engines | Dot-star rescan per repetition; polynomial blowup on failure | Anchor both ends, replace .* with explicit negated class, length-gate input first |
(.*)*, ^(.+)+$ | same five engines | Redundant outer quantifier over greedy group ("classic explode") | Delete the redundant outer quantifier |
^(\w+\s?)*$ word-splitters | same five engines | Inner optional token under star explodes path count on long non-matching tails | Validate with split()/tokenize instead of one mega-regex |
User-supplied PATTERN compiled at runtime (new RegExp(input), re.compile(input), Pattern.compile(userStr)) | ALL engines including Go/Rust RE2 | Attacker controls both pattern and subject; even linear-time engines pay per-request compile cost | Never compile attacker-controlled patterns; use fixed allowlisted patterns keyed by name |
| Engine / runtime | Backtracks? | Timeout default | Notes and mitigations |
|---|---|---|---|
Go stdlib regexp (RE2 semantics), Rust regex crate | No | n/a | Linear-time guarantee; immune to catastrophic backtracking by construction. No backreferences/lookarounds; ported patterns can silently change meaning — run pattern unit tests after migration |
| JavaScript V8 (Node.js, browsers) | Yes | None | No built-in timeout mechanism at all. JS supports neither atomic groups nor possessive quantifiers. Mitigate with npm re2 package, hand-written validators, or strict input-length gates before matching |
Python re | Yes | None | PyPI regex module accepts a timeout kwarg (regex.search(p, s, timeout=0.5)); Python 3.11+ re supports atomic groups (?>...) and possessive quantifiers ++; google-re2 bindings exist |
PCRE / PHP preg_* | Yes | None, but pcre.backtrack_limit (default 1,000,000 steps) aborts runaway matches | The limit caps worst case but CPU still burns up to the cap per call; preg_match() returns false on limit hit (silently swallows matches). PHP 7.3+ supports atomic groups and possessive quantifiers |
.NET System.Text.RegularExpressions | Yes | Infinite unless a TimeSpan is passed | Always construct with timeout: new Regex(pattern, options, TimeSpan.FromMilliseconds(500)). Atomic groups supported broadly; possessive quantifiers since .NET 7 |
Java java.util.regex | Yes | None; matching does not respond to Thread.interrupt() | Possessive quantifiers and atomic groups supported natively; drop-in RE2/J library (com.google.re2j) is linear-time; otherwise run matches in an executor thread bounded by Future.get(n, TimeUnit.SECONDS) |
| Ruby Regexp (Onigmo) | Yes | nil unless set; Ruby >= 3.2 global Regexp.timeout = 5 (seconds) | Set the global timeout at boot; atomic groups (?>...) supported |
| Need | JS/Node | Python | Java | .NET | PHP | Ruby | Go |
|---|---|---|---|---|---|---|---|
| Bounded regex execution | re2 npm package | regex module + timeout= | RE2/J or executor+Future.get(timeout) | Regex ctor with TimeSpan | keep default pcre.backtrack_limit; add length gate | Regexp.timeout = 5 at boot | already bounded |
| Non-backtracking rewrite tools | none in-language (no atomic/possessive) | 3.11+ atomic (?>..) / possessive ++ | atomic (?>..) / possessive ++ | atomic (?>..); possessive .NET 7+ | atomic (?>..) / possessive ++ (PHP 7.3+) | atomic (?>..) | n/a (already RE2) |
| Replace validation regexes entirely | bespoke parsers, URL/Intl APIs | stdlib parsers (ipaddress, email.utils.parseaddr) | dedicated validators (hibernate-validator constraints) | Uri.TryCreate, MailAddress.TryCreate | filter_var(...) | URI/Email validator gems | net.ParseIP, mail.ParseAddress |
Candidate catastrophic-backtracking shapes (nested quantified groups):
\([^()]{1,60}[+*][^()]{0,60}\)[+*{]
Quantified wildcard/dot groups such as (.*a){20}:
\(\.[^()]{0,40}[+*]\)\{[0-9]+
Overlapping alternation under repetition:
\([^()]{1,60}\|[^()]{1,60}\)[+*]
Regex construction sites to review manually (does any argument derive from request data?):
(new RegExp\(|re\.compile\(|Pattern\.compile\(|preg_match\(|preg_replace\(|Regexp\.new\(|regexp\.MustCompile|new Regex\(|Regex\.Match\()
Node synchronous CPU/blocking calls reachable from handlers:
(pbkdf2Sync|scryptSync|generateKeyPairSync|randomFillSync|hashSync|compareSync|execSync|spawnSync|readFileSync|inflateSync|gzipSync)
Whole-file-into-memory reads on upload paths:
(ReadAllBytes|readAllBytes|file_get_contents|os\.ReadFile|ioutil\.ReadFile|fs\.readFileSync|MemoryStream|toByteArray\(\))
Archive extraction sinks:
(extractall|ExtractToDirectory|ZipFile\.OpenRead|archive/zip|archive/tar|adm-zip|unzipper|extractTo|tar -x)
Unbounded pagination indicators:
(LIMIT\s*\$\{|LIMIT " ?\+|limit\s*=\s*(int|parseInt|Integer\.parseInt)|params\[.?limit|\bper_page\b|\bpage_size\b)
Quadratic string building in Java/C# loops (then confirm loop context by reading):
(String|string)\s+(result|output|sb|builder|csv|html|msg|text)\w*\s*(=|"")?\s*\+?=
Missing-limit ORM full scans:
(\.objects\.all\(\)|findAll\(\)|find\(\{\}\)\s*\.toArray|\.all\b.*each|Model\.find\(\)\s*$)
XML parser hardening flags present-or-absent check:
(defusedxml|disallow-doctype-decl|setFeature\(.http://apache.org/xml/features/disallow|XmlResolver\s*=\s*null|resolve_entities|libxml_disable_entity_loader)
Doubling method: time one match at input length n, then 2n, 4n... Because n doubles each round, LINEAR cost shows a constant ~2x growth ratio, quadratic ~4x, cubic ~8x, exponential shows ratios that keep CLIMBING (4x, then 16x, then budget hit). A hard safety budget aborts before anything hangs your workstation.
Python (python3 harness.py):
import re, time
def probe(pattern, char="a", suffix="!", start=16, max_len=8192, budget_ms=500.0):
rx = re.compile(pattern)
n, prev = start, None
while n <= max_len:
s = char * n + suffix
t0 = time.perf_counter()
try:
rx.search(s)
except Exception as e:
print("engine error:", e)
return
ms = (time.perf_counter() - t0) * 1000.0
ratio = (ms / prev) if prev else 0.0
tag = ""
if prev:
if ratio >= 4.0 and ms > 1.0:
tag = " <-- SUPERLINEAR"
print(f"n={n:6d} {ms:10.3f} ms growth={ratio:6.2f}x{tag}")
if ms > budget_ms:
print("BUDGET HIT -> treat as catastrophic backtracking; stop scaling.")
return
prev, n = ms, n * 2
probe(r"(a+)+$") # expect climbing ratios then budget hit
probe(r"^[A-Za-z0-9_.-]+$") # expect steady ~2x (linear, safe shape)
Node equivalent (node harness.js; use performance.now(), NOT Date.now() whose 1 ms resolution hides early steps):
const { performance } = require("node:perf_hooks");
function probe(re, ch = "a", suffix = "!", start = 16, maxLen = 8192, budgetMs = 500) {
let n = start, prev = null;
while (n <= maxLen) {
const s = ch.repeat(n) + suffix;
const t0 = performance.now();
re.test(s);
const ms = performance.now() - t0;
const ratio = prev ? ms / prev : 0;
console.log(
`n=${String(n).padStart(6)} ${ms.toFixed(3)} ms growth=${ratio.toFixed(2)}x` +
(prev && ratio >= 4 && ms > 1 ? " <-- SUPERLINEAR" : "")
);
if (ms > budgetMs) {
console.log("BUDGET HIT -> treat as catastrophic backtracking; stop scaling.");
return;
}
prev = ms;
n *= 2;
}
}
probe(/^(a+)+$/);
probe(/^[A-Za-z0-9_.-]+$/);
Interpretation rules:
| Observed growth per doubling | Verdict |
|---|---|
| ~2x each step, stays flat | Linear — acceptable (still record if applied to multi-MB inputs inside hot paths) |
| steady ~4x | Quadratic — fix or clamp input length tightly (CWE-407) |
| ratios climbing round over round, or early budget hit | Exponential/catastrophic — CWE-1333 finding; remediate before any live probing |
For patterns where the dangerous tail differs (e.g., digits), pass a different char/suffix (harness parameters) matching the character classes in the pattern; a trigger that never matches is what maximizes backtracking.
Model every DoS sink as source -> missing-clamp -> expensive operation. Sources: request body/query/path/header values, uploaded files (bytes, count, names), webhook bodies, message-queue messages, and second-order data stored earlier from users (rows replayed into exports/admin lists).
Sink inventory and the clamp category each requires:
| Sink class | Example sinks per stack | Required clamp category |
|---|---|---|
| Regex execution | re.match/search, .match(/re/), Pattern.compile + Matcher.matches, preg_match, Regex.IsMatch, Regexp.new | Input byte-length gate BEFORE match; fixed non-attacker-controlled pattern; engine-level timeout |
| Pattern compilation | new RegExp(v), re.compile(v) | Must not accept attacker strings at all |
| Allocation sized by input | make([]byte, n) Go, new byte[n] Java/C#, bytearray(n) Python, Buffer.alloc(n) JS, String(n) repeat tricks | n <= constant derived from server config, not raw input |
| Collection-size-driven loops | iterating req.body.items[], CSV rows, GraphQL list fields | Max item count enforced at parse boundary; algorithm no worse than O(n log n) |
| SQL LIMIT/OFFSET construction | string-interpolated LIMIT, ORM .limit(params.limit) | Default when absent + hard upper clamp + integer parse |
| Archive extractors | zipfile.extractall, archive/zip io.Copy loops, SharpCompress, System.IO.Compression | Cumulative output bytes, entry count, compression-ratio threshold |
| XML parser instances | DocumentBuilderFactory, lxml.etree.fromstring, XmlReader, simplexml_load_string, xml.Decoder | DOCTYPE/DTD disabled or entity expansion off |
| Cache setters | Redis SET key value with key containing user input | TTL mandatory; key-cardinality ceiling; eviction policy configured |
| Paid-API SDK calls | SMS/email/transcode clients called inline in handlers | Rate limit + idempotency/dedup + async queue quota |
Tracing procedure:
if len(s) > 256: reject).Worked micro-example (Node): app.post("/search", (req,res) => res.json(items.filter(i => new RegExp(req.body.q).test(i.name)))). Source req.body.q reaches TWO sinks: pattern compilation (attacker-chosen regex = hostile-pattern DoS on ANY engine) and an O(items x pattern) scan per request. Fix direction: never compile user patterns; switch to indexed substring search. Trace both facts in the finding.
Authorization rules for this entire section: run these procedures ONLY against systems you are contractually authorized to test, ideally staging. Static reading is your primary evidence; live probes are corroboration. Every procedure below uses between ONE and FOUR requests — never loops, floods, or sustained load. STOP IMMEDIATELY if you observe any of: request latency above 30 seconds, HTTP 502/503/504, OOM restart evidence, or disk/memory alerts. Confirm complexity by reading the code first; measure only what you have already proven on paper.
Measure latency with curl's built-in timer rather than external tools:
curl -s -o /dev/null -w 'status=%{http_code} time_total=%{time_total}s\n' \
-X POST https://TARGET/api/validate \
-H 'Content-Type: application/json' \
-d '{"email":"[email protected]"}'
POST /api/validate checking an email field).time_total.python3 -c "print('['*50 + '0' + ']'*50)" > d50.json
python3 -c "print('['*200 + '0' + ']'*200)" > d200.json
python3 -c "print('['*800 + '0' + ']'*800)" > d800.json
time_total and status.400/413 responses indicate a working depth/size cap (remediated state); a crash/restart at d800 indicates unbounded recursion handling (CWE-674).<?xml version="1.0"?>
<!DOCTYPE lolz [
<!ENTITY lol "lol">
<!ENTITY lol1 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;">
<!ENTITY lol2 "&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;">
<!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;">
<!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;">
<!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;">
<!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;">
<!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;">
<!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;">
<!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;">
]>
<lolz>&lol9;</lolz>
400/403 rejecting DOCTYPE = remediated (hardened parser). Cross-reference deserialization.md for entity/XXE remediation detail. One request only — the payload self-amplifies ~10^9.import zipfile, io
buf = io.BytesIO()
with zipfile.ZipFile(buf, "w", zipfile.ZIP_DEFLATED) as z:
z.writestr("zeros.bin", b"\x00" * (1024 ** 3)) # 1 GB of zeros -> roughly 1 MB stored
open("bomb.zip", "wb").write(buf.getvalue())
Nested layers multiply the effect: place bomb.zip itself as an entry inside a second archive (and repeat); each layer compounds the compression ratio. Keep YOUR test file to the single-layer ~1 GB-output version — enough to prove the point.
/proc/<pid>/status VmRSS).docker inspect <id> shows OOMKilled: true, or k8s pod restart count increments, or dmesg oom-killer lines). Instant 400/413 = ratio/output guards present (CWE-409 remediated).GET /api/items?limit=20&page=1, once GET /api/items?limit=99999999&page=1.400 (clamped). Also try limit=-1 once: negative values frequently bypass naive clamps entirely.ReDoS triggers by vulnerable shape (start small; escalate length only if nothing hangs):
| Shape | Trigger (notation) | Literal trigger |
|---|---|---|
(a+)+$ | 'a'*30 + '!' | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa! |
| `(a | a)*$, (a | aa)+$` |
(.*a){20} | 'x'*25 | 25 x's (no trailing a) |
^(\d+)*$ | '1'*30 + 'X' | 111111111111111111111111111111X |
| `(a | ab)+$` | 'a'*26 + 'c' |
CSV shape ^(\w+,)+\w+$ | 'a,'*30 + '!' | a, repeated 30 times then ! |
Deep-JSON body shape (depth attack):
{"data":[[[[[[[[[[[[[[[[[[[[{"deep":1}]]]]]]]]]]]]]]]]]]]]]}
Generator for arbitrary depth: '{"a":'*n + '1' + '}'*n (objects) or '['*n + ']'*n (arrays).
Limit-probe query parameters: ?limit=99999999&page=1, ?page_size=2147483647, ?per_page=all, ?count=-1&limit=-1, ?offset=99999999&limit=100000.
| Stack | Exact configuration |
|---|---|
| Node/Express | app.use(express.json({ limit: "100kb" })); same limit on express.urlencoded; multer: multer({ limits: { fileSize: 10485760, files: 5 } }) |
| Django | DATA_UPLOAD_MAX_MEMORY_SIZE = 2621440, FILE_UPLOAD_MAX_MEMORY_SIZE = 2621440, keep DATA_UPLOAD_MAX_NUMBER_FIELDS = 1000 (raise deliberately, never remove) |
| Flask | app.config["MAX_CONTENT_LENGTH"] = 16 * 1024 * 1024 |
| FastAPI/Starlette | No built-in cap — add ASGI middleware that rejects when Content-Length exceeds your bound and reads the body through a counting wrapper that aborts mid-stream |
| Spring Boot | spring.servlet.multipart.max-file-size=10MB, spring.servlet.multipart.max-request-size=12MB; WebFlux: spring.codec.max-in-memory-size=256KB |
| ASP.NET Core | builder.WebHost.ConfigureKestrel(o => o.Limits.MaxRequestBodySize = 10_485_760); plus [RequestSizeLimit(10_485_760)] on heavy endpoints; IIS: raise/lower <requestLimits maxAllowedContentLength> consistently |
// FIXED: Express explicit caps at boot
app.use(express.json({ limit: "100kb" }));
app.use(express.urlencoded({ extended: true, limit: "100kb" }));
// FIXED: Go has NO default body cap - wrap every body-consuming route
r.Body = http.MaxBytesReader(w, r.Body, 10<<20) // 10 MiB
CONFIG cross-ref (reverse proxy outer boundary — nginx):
server {
client_max_body_size 1m;
client_body_timeout 12s;
proxy_read_timeout 30s;
}
Apply IN ORDER until the candidate is bounded: (1) reject inputs above a tight length BEFORE matching; (2) simplify the pattern to a linear shape; (3) enable the engine's timeout/possessive features; (4) migrate engine (npm re2, Python google-re2, Java RE2/J) where the platform allows. Go/Rust stdlib need no migration — only ensure patterns were not ported expecting lookarounds/backrefs.
// VULNERABLE
Pattern USER = Pattern.compile("^([a-zA-Z0-9]+)*$"); // redundant outer star
// FIXED
Pattern USER = Pattern.compile("^[a-zA-Z0-9]+$"); // linear shape; atomic group "(?>...)" acceptable alternative
// VULNERABLE
var rx = new Regex(@"^(\d+)*$");
// FIXED
var rx = new Regex(@"^\d+$", RegexOptions.None, TimeSpan.FromMilliseconds(250)); // ALWAYS pass matchTimeout
# VULNERABLE
re.fullmatch(r"(a|aa)+", user_input)
# FIXED (PyPI regex module supports engine-level timeout)
import regex
regex.fullmatch(r"(a|aa)+", user_input, timeout=0.25) # raises TimeoutError instead of hanging
// VULNERABLE
const ok = /^(a+)+$/.test(input);
// FIXED
if (typeof input !== "string" || input.length > 256) return false; // length gate FIRST
const RE2 = require("re2");
const ok = new RE2("^(a+)+$").test(input); // linear-time engine
Possessive-quantifier support recap (use a++, (?>...) where listed): Java, .NET, PCRE/PHP 7.3+, Python 3.11+ re, Ruby Onigmo. NOT available in JavaScript — use npm re2 or restructure there.
| Language | Stream JSON | Stream CSV | Safe XML | Guard images/archives |
|---|---|---|---|---|
| Node | stream-json, NDJSON lines | csv-parse stream mode | saxes with DOCTYPE disabled | sharp (streams, pixel limits); multer byte caps |
| Python | ijson.items(f, "item") | csv.reader(open(...)) iterates lazily | defusedxml (forbids DTD/entities) | Pillow Image.MAX_IMAGE_PIXELS (~89 Mpx default) trips DecompressionBomb errors; check before extractall |
| Java | Jackson streaming JsonParser | univocity-parsers row iterator | XMLInputFactory with SUPPORT_DTD=false | Apache POI ZipSecureFile inflate-ratio guard defaults; SXSSF streaming writer |
| C# | System.Text.Json JsonDocument with JsonReaderOptions.MaxDepth (default 64) | CsvHelper csv.GetRecords() lazy enumeration | XmlReaderSettings { DtdProcessing = Prohibit, XmlResolver = null } | check archive entry sizes before ExtractToDirectory |
| PHP | stream_json/line-delimited chunks | fgetcsv() loop | XMLReader + libxml entity loader disabled | getimagesize() before load; per-file ini caps |
| Ruby | yajl/NDJSON | CSV.foreach streams | Nokogiri::XML::Reader with nonet + noent omitted | MiniMagick identify first; ActiveStorage blob validations |
| Go | json.Decoder.Token() loop | encoding/csv Reader iterates | xml.Decoder (no entity expansion by default; Strict mode) | image.DecodeConfig reads dimensions WITHOUT full decode; wrap sources in io.LimitReader |
MAX_OUTPUT_BYTES = 100 MB MAX_ENTRIES = 10,000 MAX_RATIO = 100:1 MAX_DEPTH = 1
entries = 0 ; total_out = 0
for each archive entry:
entries += 1 ; abort if entries > MAX_ENTRIES
declared = entry.uncompressed_size # from header/central directory
abort if declared > MAX_OUTPUT_BYTES
abort if entry.compressed_size > 0 and declared / entry.compressed_size > MAX_RATIO
stream-copy entry while COUNTING REAL BYTES # headers can lie; enforce during copy too
total_out += counted ; abort if total_out > MAX_OUTPUT_BYTES
if entry looks like a nested archive: abort unless MAX_DEPTH allows, recurse within REMAINING budget only
Tar-specific entry-name traversal, link handling, and path-count bombs: cross-reference file-handling.md.
// FIXED: default AND ceiling, integer-parsed
const limit = Math.min(Number.parseInt(req.query.limit ?? "20", 10) || 20, 100);
const offset = Math.max(0, Number.parseInt(req.query.offset ?? "0", 10) || 0);
Python/Ruby equivalents: limit = min(int(request.GET.get("limit", 20)), 100); per_page = [params.fetch(:per_page, 20).to_i, 100].min. Prefer cursor/keyset pagination for large tables; move exports to async jobs producing a downloadable artifact (next subsection) instead of serializing whole datasets inline.
Eager-load associations reached by list endpoints: Django .prefetch_related(...)/.select_related(...), Rails .includes(...), JPA @EntityGraph or JOIN FETCH, SQLAlchemy selectinload(...). Batch per-item cache lookups (DataLoader pattern). For GraphQL, enforce depth limiting (graphql-depth-limit) plus cost/complexity analysis (graphql-cost-analysis or equivalent validation rules) and cap resolver list sizes — detailed guidance in api-security.md.
handler: validate input -> check quota -> enqueue(job_id, idempotency_key) -> respond 202 {job_id}
worker: bounded concurrency; per-tenant quota accounting; circuit breaker on third-party failures
client: poll GET /jobs/{id}
Stack-native queues: BullMQ (Node), Celery (Python), Sidekiq (Ruby), Hangfire (.NET), asynq (Go). Transcodes, bulk imports, report generation, SMS/email fanout all belong behind this boundary.
Redis eviction policy (unbounded keys otherwise accumulate forever):
# redis.conf
maxmemory 512mb
maxmemory-policy allkeys-lru
Rules: every cache/session key derived from user input carries a TTL (SET key val EX 3600); session creation on unauthenticated routes is rate-limited (cross-ref authn-session.md and api-security.md); error handlers truncate payloads before logging (log.error("bad req len=%d", len(body)) not log.error("%s", body)); log rotation configured (logrotate unit, Docker --log-opt max-size=10m --log-opt max-file=3). Paid-call endpoints additionally get: idempotency keys, per-user daily quotas enforced server-side, and spend alerts wired to the provider account.
Body-size cap (positive AND negative):
GIVEN express.json is configured with limit 100kb
WHEN a client posts a 200 KB JSON body THEN response is 413 and nothing was buffered wholesale
WHEN a client posts a legitimate 90 KB payload THEN the request succeeds normally (negative test - real users unaffected)
Regex hardening:
GIVEN the vulnerable pattern was rewritten or given an engine timeout
WHEN the endpoint receives "a" x 30 + "!" THEN it responds within 500 ms with a normal status code
WHEN the endpoint receives typical production input THEN validation results are IDENTICAL to pre-fix behavior (no functional regression)
Pagination clamp:
GIVEN server-side clamp limit = min(param || 20, 100)
WHEN GET /items?limit=99999999 THEN at most 100 rows return
WHEN GET /items?limit=-1 THEN the default applies (no negative-bypass full scan)
WHEN GET /items (no params) THEN the default page size applies
Decompression guard:
GIVEN ratio/output/entry-count guards wrap archive extraction
WHEN bomb.zip (~1 MB storing 1 GB of zeros) is uploaded ONCE THEN an immediate 400/413 returns and service memory stays flat
WHEN a legitimate photo archive (ratio well under threshold) is uploaded THEN import succeeds completely
XML entity expansion:
GIVEN parser rejects DTD/DOCTYPE
WHEN the billion-laughs document arrives THEN instant 400/403, latency unchanged
WHEN ordinary entity-free XML arrives THEN it parses as before
Event-loop blocking:
GIVEN pbkdf2Sync-style work was moved off the request path
WHEN 5 concurrent requests hit endpoints while a login/hash operation runs THEN p95 latency stays within baseline x 1.5
// k6-style pseudocode - fixed small concurrency, short window, assertions externalized
import http from "k6/http";
import { check } from "k6";
export const options = { vus: 5, duration: "60s" }; // deliberately bounded
export default function () {
const r = http.get(`${__ENV.TARGET}/api/items?limit=20`);
check(r, { "is 200": (res) => res.status === 200 });
}
// After the run ASSERT:
// error rate < 1%, p95 latency < agreed threshold,
// zero 5xx spikes, pod/container age unchanged (no restarts), memory curve returns to baseline
.all() datasets inline.maxmemory set, an eviction policy, and TTLs on user-derived keys.Cap presence (expect hits in config/bootstrap files):
(express\.json\(\{\s*limit|MaxBytesReader|MAX_CONTENT_LENGTH|DATA_UPLOAD_MAX_MEMORY_SIZE|max-file-size|max-request-size|client_max_body_size)
Regex bounds present (expect hits wherever regexes touch input):
(TimeSpan\.FromMilliseconds|new RE2\(|com\.google\.re2j|Regexp\.timeout|timeout=\d)
Must now return ZERO hits in request-path code:
(pbkdf2Sync|compareSync|execSync|inflateSync)
Vulnerable-shape grep re-run should surface ONLY patterns annotated as reviewed/safe-engine:
\([^()]{1,60}[+*][^()]{0,60}\)[+*{]
All vectors below use availability-only impact because these flaws do not directly breach confidentiality or integrity. Compute with care and justify deviations.
| Finding class | Example CVSS v3.1 vector | Score | Notes |
|---|---|---|---|
| Unauthenticated SINGLE request hangs/crashes/OOMs a worker (ReDoS CWE-1333, zip bomb CWE-409) | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H | 7.5 High | One request, persistent effect |
| Unauthenticated multi-request exhaustion, amplification factor high (>~100x output/input or work/request) | same vector | 7.5 High | Sustained but cheap for attacker |
| Multi-request needed with LOW amplification (<10x) or effective rate limiting in place | .../C:N/I:N/A:L variant where infra demonstrably absorbs load | 5.3 Medium | Rubric: Medium-High band depending on measured factor |
| Authenticated-only reachability (any of the above behind login) | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H | 6.5 Medium | Drop roughly one severity level from its unauth counterpart |
Rubric summary: unauthenticated single-request crash/OOM = High; multi-request required = Medium-High scaled by amplification factor; authenticated-only = lower tier; third-party bill-bomb = High on financial grounds even when technical availability impact is partial — CVSS cannot price money, so carry the spend-amplification math (cost per request x attacker budget) in the narrative rather than inflating the vector.
Always state the OBSERVED amplifier (bytes-in : bytes-out, elements : queries, input chars : match time) in the report; it is the strongest severity evidence you can produce.
(a+)+$ in Go stdlib regexp or Rust regex is linear-time; verify the ENGINE before reporting (CWE-1333 does not apply).client_max_body_size protects only traffic THROUGH the proxy; direct-to-origin routes bypass it. Verify application-layer limits independently.limit accepted but harmless: some ORMs/databases enforce their own internal maximum, or responses are keyset-paginated/streamed regardless. Confirm actual row serialization before flagging.len(input) <= 256 is enforced BEFORE matching, worst case is bounded; verify gate ORDERING precedes the match call.CWE entries used in this module:
OWASP resources (stable project/community URLs):
Sibling modules in this skillset referenced above: api-security.md (rate limiting, GraphQL depth/cost budgets), deserialization.md (XML entities, XXE hardening), file-handling.md (tar entry bombs, path traversal), authn-session.md (session-creation spam).
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/aegis:aegis-denial-of-servicefrom Aegis Skills
npx claudepluginhub as-foss/aegis-skills --plugin aegis40 skills in this plugin
/aegis-api-securityAudit playbook module for API-specific security failures covering mass assignment, missing rate limits and pagination caps, GraphQL/gRPC misconfiguration, REST hygiene gaps, API key mishandling, and WebSocket/SSE access-control defects across all mainstream web frameworks./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-baas-platformAudits Backend-as-a-Service and managed-platform configuration - Supabase RLS, Firebase security rules, connection-string databases, serverless host exposure, payment-webhook integrity, and managed CMS posture - for broken-access-control footguns that expose or corrupt production data./aegis-backup-drAudits backup hygiene and disaster-recovery readiness for Linux hosts — job inventory and coverage-gap analysis, destination tiering against the 3-2-1-1-0 pattern, encryption and key-custody posture, restore documentation and drill evidence, and ransomware resilience — using read-only discovery sweeps, fill-in RTO/RPO and recovery-order worksheets, and remediation skeletons.Other plugins' skills for the same job