canonicalization-order-v1
4 rules · Keryn Software Licence · rules 0.8.0 · all packs
How to read a rule
- Severity
- How bad the finding is if it is real:
errorfails a default gate,warningandinfodo not. - Confidence
- P0 exploitable as written; P1 dangerous in context; P2 a heuristic or a posture check: confirm by reading the code.
- False-positive risk
- low: an exact API or flag, so hits are almost always real; medium: the pattern is legitimate in many programs, so check each hit; high: it finds a lead to confirm, so expect benign hits.
- Edge
- The relationship the finding sits on. reaches: content or traffic gets to a thing; calls: one thing invokes another; reads: one thing reads from another; writes: one thing writes to another; sends: data leaves for another party; grants: authority is given or left unchecked; depends_on: something relies on a component it does not verify; trusts: one party believes another without evidence. The boundary it crosses, when there is one: user->prompt (untrusted input reaching a prompt); model->code (model output reaching code, a shell, a query or a page); secret->outside (a secret leaving the trusted side); supply-chain (code, models or prompts pulled in from outside).
- Taxonomy chips
- References for readers who work in OWASP LLM 2025, OWASP Agentic, CWE or NIST AI RMF. They say where a rule belongs, not that a framework is satisfied.
keryn.canon.py.validate-before-decode
Section titled “keryn.canon.py.validate-before-decode”error python python
A value is validated or allow-listed, then decoded/normalized (unquote, b64decode, realpath, normalize), then the decoded result reaches a path/command/URL sink. The check ran on the pre-decode bytes, so encoded input (%2e%2e, double-encoding) passes the guard and the sink sees something else. Validate after you fully decode and normalize, on the final value.
Confidence P1: dangerous in context. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.
Edge inspected: trusts one party believes another without evidence.
CWE-179 CWE-180 CWE-20 LLM01 ASI02
Fix: Decode and normalize first, then validate the final value: resolve the path with os.path.realpath and confirm it is inside the allowed root; URL-decode fully (checking for double-encoding) before matching an allow-list; then pass that same value to the sink.
References: https://cwe.mitre.org/data/definitions/179.html · https://docs.python.org/3/library/urllib.parse.html#urllib.parse.unquote · https://docs.python.org/3/library/os.path.html#os.path.realpath
keryn.canon.ts.validate-before-decode
Section titled “keryn.canon.ts.validate-before-decode”error typescript, javascript typescript, nodejs
A value is validated or allow-listed, then decoded/normalized (decodeURIComponent, unescape, path.resolve, normalize), then the decoded result reaches a path/command/URL sink. The check ran on the pre-decode bytes, so encoded input slips past it. Decode and normalize first, then validate the final value before the sink.
Confidence P1: dangerous in context. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.
Edge inspected: trusts one party believes another without evidence.
CWE-179 CWE-180 CWE-20 LLM01 ASI02
Fix: Decode and normalize first, then validate: resolve the path and confirm it stays inside the allowed root, fully URL-decode before matching an allow-list, then pass that value to the sink.
References: https://cwe.mitre.org/data/definitions/179.html · https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent · https://nodejs.org/api/path.html#pathresolvepaths
keryn.canon.go.validate-before-decode
Section titled “keryn.canon.go.validate-before-decode”error go go
A value is validated/allow-listed, then decoded or normalized (QueryUnescape, filepath.Clean), then the decoded result reaches a path/command/request sink. The check ran on pre-decode bytes. Decode and normalize first, then validate the final value before the sink.
Confidence P1: dangerous in context. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.
Edge inspected: trusts one party believes another without evidence.
CWE-179 CWE-180 CWE-20 LLM01 ASI02
Fix: Decode and normalize first (url.QueryUnescape, filepath.Clean), then validate the final value and confirm it stays inside the allowed root before the sink.
References: https://cwe.mitre.org/data/definitions/179.html · https://pkg.go.dev/net/url#QueryUnescape
keryn.canon.php.validate-before-decode
Section titled “keryn.canon.php.validate-before-decode”error php php
A value is validated/allow-listed, then decoded or normalized (urldecode, rawurldecode, realpath), then the decoded result reaches a path/command/request sink. The check ran on pre-decode bytes. Decode and normalize first, then validate the final value before the sink.
Confidence P1: dangerous in context. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.
Edge inspected: trusts one party believes another without evidence.
CWE-179 CWE-180 CWE-20 LLM01 ASI02
Fix: Decode and normalize first (rawurldecode, realpath), then validate the final value and confirm it stays inside the allowed root before the sink.
References: https://cwe.mitre.org/data/definitions/179.html · https://www.php.net/manual/en/function.rawurldecode.php