본문으로 건너뛰기
Skillpedia
보안8.0k · #12672

constant-time-analysis

하는 일

비밀 값이 속도를 드러낼 수 있는 컴파일된 암호 코드의 명령어를 검사한 다음, 실제로 중요한 것을 가려냅니다. 서명, 암호화, 키 처리를 다루는 개발자와 검토자를 위한 것입니다.

사용하는 경우

  • ✓개발자가 서명, 암호화 또는 키 파생 루틴을 구현하거나 검토할 때.
  • ✓코드가 키나 비밀에서 파생된 값을 나누거나 나머지를 구하는 경우.
  • ✓누군가 상수 시간 프로그래밍이나 KyberSlash 문제에 대해 물을 때.

스킬 링크

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

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/trailofbits/skills/blob/main/plugins/constant-time-analysis/skills/constant-time-analysis/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“서명 함수에서 비밀 값에 따라 실행 속도가 달라져 타이밍이 새는 곳이 있는지 확인해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

이 스킬은 코드를 컴파일하고, 어셈블리나 바이트코드에서 느리고 시간이 달라지는 명령어를 찾습니다. 그다음 표시된 연산 중 실제로 비밀 값을 건드리는 것을 판단하고, 언어별 수정 방법을 설명합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 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

자주 묻는 질문

타이밍을 측정하려고 코드를 실행하나요?

아니요. 이 스킬은 컴파일러 출력을 검사하며, 검사 대상 코드는 절대 실행하지 않습니다.

어떤 언어를 지원하나요?

C, C++, Go, Rust, Swift, Java, Kotlin, C#, PHP, JavaScript, TypeScript, Python, Ruby를 나열합니다.

캐시 기반 사이드 채널도 찾나요?

아니요. 어셈블리 관점에서는 캐시와 다른 마이크로아키텍처 사이드 채널이 보이지 않습니다.

상세 정보

작성자의 원본 설명

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

인기도

GitHub 스타
8.0k
순위
#12672
라이선스
CC-BY-SA-4.0
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬