Aller au contenu
Skillpedia
Sécurité8.0k · #12672

constant-time-analysis

Ce qu’il fait

Inspecte le code cryptographique compilé à la recherche d'instructions dont la vitesse pourrait révéler des valeurs secrètes, puis détermine lesquelles comptent vraiment. Il s'adresse aux développeurs et relecteurs qui travaillent sur les signatures, le chiffrement et la gestion des clés.

Quand l’utiliser

  • ✓Quand un développeur implémente ou relit une routine de signature, de chiffrement ou de dérivation de clés.
  • ✓Quand du code divise ou calcule un reste à partir d'une valeur issue d'une clé ou d'un secret.
  • ✓Quand quelqu'un pose des questions sur la programmation à temps constant ou sur le problème KyberSlash.

Lien du skill

https://github.com/trailofbits/skills/blob/main/plugins/constant-time-analysis/skills/constant-time-analysis/SKILL.md

Copiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.

Comment l’utiliser

Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.

Message prêt à coller

Utilise ce skill pour m’aider : https://github.com/trailofbits/skills/blob/main/plugins/constant-time-analysis/skills/constant-time-analysis/SKILL.md Lis le fichier SKILL.md de ce lien et suis ses instructions pour ma tâche.
Envie que votre IA trouve seule des skills comme celui-ci ?Installez le MCP gratuit de Skillpedia : une ligne, et elle cherche parmi 15 000+ skills avant chaque tâche.Installer en 1 minute →

Exemple de demande à votre IA

“Vérifie ma fonction de signature pour détecter des fuites de temps où des valeurs secrètes pourraient changer sa vitesse d'exécution.”

5 nouveaux skills par semaine. 1 minute de lecture.

Comment ça marche

Le skill compile le code et inspecte l'assembleur ou le bytecode à la recherche d'instructions lentes et à temps variable. Il détermine ensuite lesquelles des opérations signalées touchent réellement des valeurs secrètes, et explique les corrections propres à chaque langage.

Contenu technique (SKILL.md original)

Texte original de l’auteur, en anglais, directement depuis 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-testing skill from the testing-handbook-skills plugin, 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

Questions fréquentes

Exécute-t-il le code pour mesurer le temps ?

Non. Il inspecte la sortie du compilateur et n'exécute jamais le code testé.

Quels langages prend-il en charge ?

La description cite C, C++, Go, Rust, Swift, Java, Kotlin, C#, PHP, JavaScript, TypeScript, Python et Ruby.

Détecte-t-il les canaux auxiliaires liés au cache ?

Non. La vue assembleur ne voit pas les canaux auxiliaires liés au cache ni les autres canaux microarchitecturaux.

Détails

Description originale de l’auteur

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

Popularité

Étoiles GitHub
8.0k
Position au classement
#12672
Licence
CC-BY-SA-4.0
Mis à jour
02/11/2026

Ce skill vous est-il utile ?

0

Connectez-vous pour voter.

Commentaires

  • …

Autres skills de ce dépôt

Skills similaires