From prodsec-skills
Detects timing side-channel vulnerabilities in cryptographic code across 13 languages. Use when implementing or reviewing crypto, encountering secret-dependent division/branches, or constant-time programming questions.
How this skill is triggered — by the user, by Claude, or both
Slash command
/prodsec-skills:constant-time-analysisThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Analyze cryptographic code to detect operations that leak secret data through execution timing variations.
Analyze cryptographic code to detect operations that leak secret data through execution timing variations.
Companion analyzer: The upstream Trail of Bits prodsec-skills constant-time-analysis plugin ships ct_analyzer/analyzer.py and per-language reference docs (see upstream Trail of Bits prodsec-skills for companion files).
User writing crypto code? ──yes──> Use this skill
│
no
│
v
User asking about timing attacks? ──yes──> Use this skill
│
no
│
v
Code handles secret keys/tokens? ──yes──> Use this skill
│
no
│
v
Skip this skill
Concrete triggers:
/ or % operators on secret-derived valuessign, verify, encrypt, decrypt, derive_keyBased on the file extension or language context, use the matching upstream reference under plugins/constant-time-analysis/skills/constant-time-analysis/references/:
| Language | File Extensions | Guide (upstream filename) |
|---|---|---|
| C, C++ | .c, .h, .cpp, .cc, .hpp | compiled.md |
| Go | .go | compiled.md |
| Rust | .rs | compiled.md |
| Swift | .swift | swift.md |
| Java | .java | vm-compiled.md |
| Kotlin | .kt, .kts | kotlin.md |
| C# | .cs | vm-compiled.md |
| PHP | .php | php.md |
| JavaScript | .js, .mjs, .cjs | javascript.md |
| TypeScript | .ts, .tsx | javascript.md |
| Python | .py | python.md |
| Ruby | .rb | ruby.md |
constant-time-analysis plugin)uv run ct_analyzer/analyzer.py <source_file>
uv run ct_analyzer/analyzer.py --warnings <source_file>
uv run ct_analyzer/analyzer.py --func 'sign|verify' <source_file>
uv run ct_analyzer/analyzer.py --json <source_file>
uv run ct_analyzer/analyzer.py --arch x86_64 crypto.c
uv run ct_analyzer/analyzer.py --arch arm64 crypto.c
uv run ct_analyzer/analyzer.py --opt-level O0 crypto.c
uv run ct_analyzer/analyzer.py --opt-level O3 crypto.c
Bytecode/IL analysis; --arch / --opt-level do not apply.
| Language | Requirements |
|---|---|
| C, C++, Go, Rust | Compiler in PATH (gcc/clang, go, rustc) |
| Swift | Xcode or Swift toolchain (swiftc in PATH) |
| Java | JDK with javac and javap in PATH |
| Kotlin | Kotlin compiler + JDK (javap) in PATH |
| C# | .NET SDK + ilspycmd |
| PHP | PHP with VLD extension or OPcache |
| JavaScript/TypeScript | Node.js in PATH |
| Python | Python 3.x in PATH |
| Ruby | Ruby with --dump=insns support |
macOS: Homebrew Java / .NET may be keg-only — add to PATH (see upstream vm-compiled.md).
| Problem | Detection | Fix |
|---|---|---|
| Division on secrets | DIV, IDIV, SDIV, UDIV | Barrett reduction or multiply-by-inverse |
| Branch on secrets | JE, JNE, BEQ, BNE | Constant-time selection (cmov, bit masking) |
| Secret comparison | Early-exit memcmp | Use crypto/subtle or constant-time compare |
| Weak RNG | rand(), mt_rand, Math.random | Use crypto-secure RNG |
| Table lookup by secret | Array subscript on secret index | Bit-sliced lookups |
PASSED — No variable-time operations detected.
FAILED — Dangerous instructions found. Example:
[ERROR] SDIV
Function: decompose_vulnerable
Reason: SDIV has early termination optimization; execution time depends on operand values
CRITICAL: Not every flagged operation is a vulnerability. The tool has no data flow analysis — it flags ALL potentially dangerous operations regardless of whether they involve secrets.
For each flagged violation, ask: Does this operation's input depend on secret data?
Identify the secret inputs to the function (private keys, plaintext, signatures, tokens)
Trace data flow from the flagged instruction back to inputs
Common false positive patterns:
// FALSE POSITIVE: Division uses public constant, not secret
int num_blocks = data_len / 16; // data_len is length, not content
// TRUE POSITIVE: Division involves secret-derived value
int32_t q = secret_coef / GAMMA2; // secret_coef from private key
Document your analysis for each flagged item
| Question | If Yes | If No |
|---|---|---|
| Is the operand a compile-time constant? | Likely false positive | Continue |
| Is the operand a public parameter (length, count)? | Likely false positive | Continue |
| Is the operand derived from key/plaintext/secret? | TRUE POSITIVE | Likely false positive |
| Can an attacker influence the operand value? | TRUE POSITIVE | Likely false positive |
npx claudepluginhub redhatproductsecurity/prodsec-skills --plugin prodsec-skillsAnalyzes cryptographic code in C/C++, Go, Rust, Java, Python, JS/TS, PHP, etc., to detect non-constant-time operations leaking secrets via timing side-channels.
Detects timing side-channel vulnerabilities like secret-dependent branches and divisions in cryptographic code for Go, Rust, Java, Kotlin, C#, PHP, JS/TS, Python, Ruby.
Detects timing side-channel vulnerabilities like secret-dependent branches and divisions in cryptographic code for Go, Rust, Java, Kotlin, C#, PHP, JS/TS, Python, Ruby.