constant-time-analysis
Qué hace
Inspecciona código criptográfico compilado en busca de instrucciones cuya velocidad podría revelar valores secretos, y luego separa cuáles importan de verdad. Es para desarrolladores y revisores que trabajan con firmas, cifrado y manejo de claves.
Cuándo usarla
- ✓Cuando un desarrollador implementa o revisa una rutina de firma, cifrado o derivación de claves.
- ✓Cuando el código divide o calcula el resto de un valor derivado de una clave o un secreto.
- ✓Cuando alguien pregunta por la programación de tiempo constante o por el problema KyberSlash.
Link de la skill
https://github.com/trailofbits/skills/blob/main/plugins/constant-time-analysis/skills/constant-time-analysis/SKILL.mdCópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.
Cómo usar
La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.
Mensaje listo para pegar
Para Claude Code, Codex o Cursor: ejecútalo en la carpeta del proyecto y la skill queda instalada.
Descarga el SKILL.md y ponlo en la carpeta de skills de tu agente.
Ejemplo de qué pedirle a la IA
“Revisa mi función de firma en busca de fugas de tiempo, donde valores secretos podrían cambiar la velocidad de ejecución.”
5 skills nuevas por semana. 1 minuto de lectura.
Cómo funciona
La skill compila el código e inspecciona el ensamblador o el bytecode en busca de instrucciones lentas de tiempo variable. Luego decide qué operaciones marcadas tocan realmente valores secretos, y explica las correcciones propias de cada lenguaje.
Contenido técnico (SKILL.md original)
Texto original del autor, en inglés, directo de GitHub.
Constant-Time Analysis
Compile the code, inspect the emitted assembly or bytecode for variable-time instructions, then decide which of the flagged operations actually touch secrets. The compilation step is mechanical; the triage step is the work.
When to Use
- Implementing or reviewing a signature, encryption, KEM, or key derivation routine
- Code applies
/or%to a value derived from a key, plaintext, nonce, or token - The user mentions "constant-time", "timing attack", "side-channel", or "KyberSlash"
- Reviewing functions named
sign,verify,encrypt,decrypt,derive_key
When NOT to Use
- Measuring timing variance on a running binary — use the
constant-time-testingskill from thetesting-handbook-skillsplugin, which covers dudect and statistical approaches and may not be installed. This skill inspects compiler output statically and never executes the code under test. - Non-cryptographic code, or crypto code where every input is public
- High-level API usage where a vetted library owns the constant-time guarantees
- Cache and other microarchitectural side channels — the assembly view cannot see them
Language Routing
Read the guide for the target language before interpreting any findings; each one lists that language's dangerous instructions and the idiomatic constant-time replacements.
| Guide | Languages |
|---|---|
| references/compiled.md | C, C++, Go, Rust |
| references/swift.md | Swift |
| references/vm-compiled.md | Java, C# |
| references/kotlin.md | Kotlin |
| references/php.md | PHP |
| references/javascript.md | JavaScript, TypeScript |
| references/python.md | Python |
| references/ruby.md | Ruby |
Running the Analyzer
The analyzer takes one file and detects the language from its extension. Always pass --warnings:
uv run {baseDir}/ct_analyzer/analyzer.py --warnings <source_file>
Without it the analyzer reports only error-severity findings, which means division, modulo and weak RNG. Four detector families are warning severity and stay silent: secret-dependent branches, early-exit comparison (memcmp, strcmp, .equals, ==), table lookups indexed by a secret, and variable-time encoding. Early-exit comparison of an authentication tag is the most common timing bug in real code — Lucky Thirteen was exactly that — so a default run is quiet about the finding you are most likely to have.
| Flag | Effect |
|---|---|
--warnings |
Add the four warning-severity families above. Pass it every time |
--func <regex> |
Restrict output to function names matching the regex |
--json |
Machine-readable output |
--github |
GitHub Actions annotations |
--arch <target> |
Target architecture (x86_64, arm64, riscv64, ...) — native languages only |
--opt-level <level> |
Optimization level (O0 through O3, Os, Oz) — native languages only |
--compiler <name> |
Override compiler choice (gcc, clang, go, rustc, swiftc) |
Narrow a large file to the routines that handle secrets with a regex, for example --func 'sign|verify'.
Run natively compiled code (C, C++, Go, Rust, Swift) at more than one --arch and --opt-level. Division timing and branch lowering are architecture- and optimization-dependent: x86_64 IDIV and arm64 SDIV differ, and a cmov at -O2 can become a branch at -O0. A single clean run proves one configuration safe, not the code.
How --arch crosses depends on the toolchain. clang crosses with --target and needs no second compiler, but any source that includes libc headers also needs that target's C library headers — libc6-dev-riscv64-cross and friends — or it fails with bits/libc-header-start.h file not found. Go cross-builds through GOARCH, though go tool objdump has no riscv64 disassembler. A GNU cross toolchain is a separate binary, so gcc needs it named explicitly — --compiler x86_64-linux-gnu-gcc, --compiler riscv64-linux-gnu-gcc — and nothing is substituted for you, so the report always names the binary that ran. rustc needs the target's standard library (rustup target add), and Swift on Linux targets only the host. Compare against the toolchain that builds your product, not whichever cross build a distribution packages.
**Re-run the whole
Preguntas frecuentes
¿Ejecuta el código para medir el tiempo?
No. Inspecciona la salida del compilador y nunca ejecuta el código que se revisa.
¿Qué lenguajes soporta?
La descripción enumera C, C++, Go, Rust, Swift, Java, Kotlin, C#, PHP, JavaScript, TypeScript, Python y Ruby.
¿Encuentra canales laterales de caché?
No. La vista del ensamblador no puede ver los canales laterales de caché ni otros canales microarquitectónicos.
Detalles
Descripción original del autor
Detects timing side-channel vulnerabilities in cryptographic code. Use when implementing or reviewing crypto code, encountering division on secrets, secret-dependent branches, or constant-time programming questions in C, C++, Go, Rust, Swift, Java, Kotlin, C#, PHP, JavaScript, TypeScript, Python, or Ruby.
repo: trailofbits/skills
Popularidad
- Estrellas en GitHub
- 8,0 mil
- Posición en el ranking
- #12672
- Licencia
- CC-BY-SA-4.0
- Actualizada
- 2/11/2026
Comentarios
- …
Más skills de este repositorio
audit-context-building
8,0 milAyuda a tu agente a conocer un código desconocido antes de una revisión de seguridad, mapeando qué supone, garantiza y necesita cada función.
algorand-vulnerability-scanner
8,0 milAyuda a tu agente a revisar contratos de Algorand en TEAL o PyTeal en busca de 11 problemas de seguridad comunes, como el rekeying o las tarifas sin control.
audit-prep-assistant
8,0 milAyuda a tu agente a preparar tu código para una auditoría de seguridad externa, con análisis estático, pruebas, limpieza de código muerto y buena documentación.
cairo-vulnerability-scanner
8,0 milAyuda a tu agente a revisar contratos de Cairo en StarkNet en busca de 6 problemas graves, como desbordamientos, mensajes arriesgados entre capas y firmas repetidas.
Skills parecidas
reverse-engineer-anything
422 milAyuda a tu agente a revisar apps y paquetes ya publicados para explicar sus funciones, comparar versiones o guiar una reconstrucción, usando la herramienta REA.
1password
394 milAyuda a tu agente a instalar la CLI de 1Password, iniciar sesión y leer o inyectar secretos sin imprimir sus valores en el chat.
healthcheck
394 milAyuda a tu agente a auditar el ordenador o servidor que ejecuta OpenClaw en busca de riesgos de seguridad, como SSH, cortafuegos, actualizaciones y copias de seguridad, y después sugerir arreglos seguros.