This is the instruction file of an agent skill named classifying-key-weaknesses. An AI agent that has the skill installed reads it when asked to triage a key finding. Download the skill as a zip: it contains this file, the criteria, the decision guide, the schema, the examples and a checker script. Unpack it into the agent's skills directory.
Classifying key weaknesses
Turn a description of a key and what is known about it into findings, evidence levels and one disposition, using the Key Weakness Classification (KWC). KWC is a research proposal, not a standard, and is unrelated to CWE; say so when reporting to people who may take the class names as established.
Numerical value, generation probability, guess rank and attack cost are different quantities. "Weak" always needs an objective and an attack model.
Classes
Nonexclusive. Answer every question; never stop at the first match.
| Code | Name | The weakness lies in |
|---|---|---|
| A1 | Primitive-weak key | The keyed transformation (oracle access) |
| A2 | Problem-instance-weak key | The public mathematical instance derived from the key |
| B1 | Low-guesswork key | A named search strategy and budget |
| B2 | Predictably generated key | The process that produced or provisioned the key |
| C1 | Relationally vulnerable key | Data from outside the instance: other keys, runs |
| C2 | Compromised key | An unauthorized party knows or has had the key |
| C3 | Policy-inadequate key | A named policy, version and rule |
| - | Invalid key | Fails admissibility rules; outside A1 to C3 |
Procedure
- Name the secret and its role (
long-term,ephemeral,nonce,seed,generator-state). If the defect lies in a nonce or seed, write one report for that secret and one for the long-term key, linked. - Work through steps 1 to 8 of references/decision-guide.md for each secret. For each yes, record what the step asks for. A no needs no entry; explain a no that a reader would expect to be a yes in a finding's or the disposition's
note. - Record the descriptors that apply (guide step 9): accessibility, lengths, generator fingerprint. They are not classes.
- Give each finding an evidence level; give a B2 finding a second level for its cause (guide step 10).
- Apply the disposition rules in order; the first match decides (guide step 11).
- Write the report in the format of references/report-schema.yaml. Start from the closest file in references/examples/, then recheck every evidence level against your case: the examples' levels come from their own facts.
- Put a check that fired in the finding's
detection. - Use the top-levelscanblock for the list of checks run, including those that did not fire. Omitscananddetection.toolwhen no tool was involved. -sourcestakes labels from the repository's bibliography, which is not bundled: omit it, and name your own sources innote. - Validate:
python3 <skill dir>/scripts/check_report.py report.yaml(needs PyYAML; runs from any directory). It checks the schema and recomputes the disposition from your findings. Fix every line it prints. A pass means the report is well formed and its disposition follows from its findings. It does not check that the classes or evidence levels are justified. - Tell the user: each finding in the notation of classification II.2 with its evidence level, the disposition and the rule that gave it, what is not known (often the cause), and that the classification is a research proposal. Follow the wording rules below.
Read references/classification.md when a step is unclear or a case sits on a boundary. It is the authority; the guide restates it. Where to look: cost and \(\rho\), I.2; group A and \(\kappa\), I.3; B1 and B2, I.4; C1, C2, C3, I.5; invalid keys and descriptors, I.6; evidence levels, II.1; finding notation, II.2; disposition, II.3; tool checks, II.4.
\(\lambda\) is the security level the key's use requires, in bits; lambda_required
records it. Take it from the policy in force, or from the construction's nominal
level (112 for RSA-2048, 128 for P-256 and Ed25519, 192 for P-384, the key
length in bits for a symmetric key).
Where raters go wrong
These come from tests with independent raters and from errors caught in the source material. Check each before finishing.
B1 and B2
- B1 needs a named strategy. Record B1 only for a search that was run against the key or that a named tool or party uses. Some order reaches every key early; that is not a finding. A key on a published list is B1 only if a search over that list is named.
- B2 covers the whole process. A key copied from documentation, a fixed firmware key, and a small RSA exponent chosen on purpose are all B2, as is a faulty random generator. State the cause.
- B2 never follows from the public key alone. Every public key determines its private key. Judge B2 from information about the process: seeds, state, other outputs, a known defect.
- One odd key. One key in a subset named before looking supports B2 at indicated only if the chance of such a match under correct generation is stated and small and the generator is not audited. Credible needs several matches or provenance. An audited generator gives no B2. A pattern noticed after looking is at most hypothesized and gives no finding.
- Secret nonce or public nonce. A repeated or predictable secret value (ECDSA nonce) is B2, by fault or by design; the long-term key is C1
auxiliary-secret. A repeated public value that only has to be unique (AEAD nonce) is not B2 and gets no report; the key is C1cross-execution(seereferences/examples/aead-nonce-reuse.yaml). - Small scalars. A small private scalar is cheap to find because it lies in a short interval (A2) and because something put it there (B2, cause often unknown). Never blame the value.
Group A and C1
- A or C1. An attack using only this key's own public data or oracle is group A. One that needs another key, another run, signatures exposing a nonce, or a related-key oracle is C1. Close primes: A2. Shared prime: C1.
- Route 1 threshold. A concrete attack needs \(\sigma\ge\sigma_{\min}\). Take the threshold from the policy or the user; where none is given use the default, 16 bits. Treat an attack as a growing family only if you can cite a growth rate.
- Objective of a relation finding. The relation itself gives
dist. Recordconf,forgeorreconly with the setting of use that gives it, and markfeasibleonly if that is this key's deployment. An involution key isconfin output feedback mode (every second keystream block equals the IV) anddistwhen no mode is stated. One finding per class, strongest supported objective; name the others in the note. - No rho outside recovery. For
dist,forgeorconfwriterho: not applicableand report queries, kappa and the excess. Test cost against the cost of listing the class is not a rho. - Small class. A key at credible or above in a group A class that can be listed within the budget (the four DES weak keys) is recoverable by trying the members: set
attack.listing_feasible: truewithclass_size. Rule 2 applies; do not change the objective or claim a structural recovery attack. - Pervasive classes still get A1. Almost any subset of polynomial-MAC keys is a forgery class. Record A1[forge] and state that the finding describes the primitive.
- Short key length is C3. A length at which the generic attack works on every key has no subset advantage, so it is not A2. Record C3 with the named policy, plus the accessibility descriptor. If the case names no policy, record no C3 and say so; never pick a policy yourself.
- Invalid keys. A scalar of 0 or a value outside the allowed range is invalid: rule 0, no class.
C2 and published values
- Say who you took as authorized. When the case is silent, treat the key's owner and operator as authorized and everyone else, including researchers and scanners, as outside; state the assumption in a note.
- C2 needs an unauthorized party. Recovery by an outside scanner or researcher is C2 (party: detector). Recovery by the owner's auditor is not C2; rule 2 still applies. A feasible attack nobody has run is not C2.
- A key shared by many devices is B2 and C2. It is not C1. The duplication demonstrates the B2 effect. The other holders make it C2 (mode
shared) at credible, demonstrated once a copy is extracted. Seereferences/examples/shared-device-key.yaml; do not copyconstant-generator.yaml, whose key is public. - Published values. A published value is C2 only if an outsider can link it to this key without guessing: a private key for this public key, or a product's default key. A symmetric key that equals a test vector is B1 if a named search uses the vector list, B2 if it was copied, and not C2.
Evidence levels
- Cause levels. Demonstrated: defect located in the code, firmware or image, or reproduced. Credible: stated by the responsible party, which is whoever generated, provisioned or operates the key or built the process; a vendor qualifies. At most indicated: claimed by someone else, or the effect is observed (many devices share a key) and the mechanism has not been located.
- Level of an A or C1 finding. It is the weaker of two claims: the attack works as stated, and it covers this key. A published proof alone is at most credible; demonstrated needs the effect shown on this key. A
confbreak deduced from the mode is credible until shown. See guide step 10. - A key said to be public. Demonstrated when the published private key was checked against this public key. Credible on a match of the full public key, or a collision-resistant hash of it, against a maintained list of keys whose private keys are published. A specific claim naming this key with no artifact is indicated, which gives
investigate. Record the level of the publication claim on the C2 finding.
Disposition and budgets
- Rule 2 and B1. Rule 2 fires on recovery demonstrated with adversary-accessible information, whatever the class. A B1 strategy that was run and found the key sets
strategy.recovered: true, stays B1, and is treated as compromised. A B1 finding without a recovery falls to rule 5. - Who ran the guess. If an outside party ran the B1 strategy and found the key, that party now knows it: add C2 (mode
recovered), and rule 1 decides. Rule 2 decides for B1 only when an authorized party ran the search. - Rule 2 and distinguishers. Rule 2 also fires on a group A or C1 finding at credible or above with recovery, forgery or confidentiality marked feasible. A distinguisher alone never fires it. The generic bound is the generic attack for
rec, and for other objectives the advantage against the ideal counterpart in the same setting of use. - Budgets. A number with its unit (
2^8 guesses) or a profile:commodityis 2^64 operations (the default),well-resourcedis 2^80 (state why). A cost equal to the budget is within it. Both are conventions and estimate no real attacker; a policy's budget overrides them.
Quantities for group A
Report these when a finding is A1 or A2; definitions are in classification I.2 and I.3.
- Subset, algorithm, and full cost: precomputation, memory, number of targets. A precomputed table over the subset is listing, not structure.
- \(\rho\): the cheaper of listing the subset and the generic attack, divided by the attack's cost. Near 1 means no structural advantage.
- The subset advantage separately: for a P-384 scalar below \(2^8\), 184 bits come from the key lying in a tiny set and 4 bits from group structure.
- For a relation on the keyed map (Route 2): the prevalence ratio \(\kappa\) against an ideal cipher or function. Near 1 rejects the class; it clears no key.
- Mass under uniform generation.
Disposition
| Rule | Condition | Action |
|---|---|---|
| 0 | Invalid | reject-invalid |
| 1 | C2 at credible or above | treat-as-compromised |
| 2 | Recovery demonstrated (A, C1, or B1 with recovered: true); or A or C1 at credible or above with recovery, forgery or confidentiality feasible; or group A at credible or above with listing_feasible |
treat-as-compromised |
| 3 | B2 at credible or above (effect or cause) with a \(\lambda\) shortfall | treat-as-compromised |
| 4 | C3 rule that mandates rejection | reject-by-policy |
| 5 | Any finding at indicated or above, counting a B2 cause level | investigate |
| 6 | Otherwise | none |
"Investigate" asserts no defect. "None" does not certify the key.
Wording rules
- Name the class with its parameters and objective: "A2[rec], interval \([1,2^8)\), baby-step giant-step", never a bare "weak".
- "Weak key" only for A1 or A2, with the objective.
- "Vulnerable key" only for A1, A2, B2, C1 or C2 at credible or above. Otherwise "key finding".
- Costs are best known classical costs. Write "no faster attack is known", never "cannot be attacked faster".
- Entropy describes a generator, never one key.
- A clean scan: "checks X, Y, Z did not fire". Never "the key is secure".
- A blocklist match or recovered key supports that specific finding. It is not a root cause.
Scope
Classify and report. Never recover, factor or brute-force a real key that the user is not authorized to test, and never run this against live systems. Toy and synthetic keys are fine for illustration.
References
- references/decision-guide.md: the step-by-step questions, evidence table, disposition flowchart, worked cases. Read first.
- references/classification.md: full membership criteria, definitions, boundaries, decision log. The authority.
- references/report-schema.yaml: the report format.
- references/examples/: sixteen worked reports to copy from.
- references/gotchas.md: reasoning traps about entropy, small keys, blocklists and cost claims.
scripts/check_report.py is the entry point; it calls scripts/check_reports.py.
Everything under references/ and scripts/check_reports.py is generated from
the keyweakness repository (https://keyweakness.org) by tools/build_skill.py. Never edit those copies.
Pointers inside them to sources/, agent_docs/, experiments/ or 02 §n lead
into that repository and are not needed to apply the skill. Where a copy
mentions tools/check_reports.py, use scripts/check_report.py here.