Detect timing attacks, cache timing, and branch prediction vulnerabilities in source code.
Identify side-channel vulnerabilities in cryptographic implementations and security-critical code.
- Timing Attack Detection: Find non-constant-time comparisons and secret-dependent operations
- Cache Timing Analysis: Detect table-based crypto operations vulnerable to cache attacks
- Branch Prediction Analysis: Identify data-dependent branching patterns
- Constant-Time Checks: Verify cryptographic implementations use constant-time operations
- Risk Scoring: Calculate security risk scores based on vulnerability severity
- Multi-Language Support: Analyze Go, C/C++, Rust, Java, Python, JavaScript, and more
git clone https://github.com/hallucinaut/sidedetect.git
cd sidedetect
go build -o sidedetect ./cmd/sidedetect
sudo mv sidedetect /usr/local/bin/go install github.com/hallucinaut/sidedetect/cmd/sidedetect@latest# Scan entire project directory
sidedetect scan ./myproject
# Scan specific directory
sidedetect scan /path/to/src# Analyze a specific file
sidedetect analyze crypto.go
sidedetect check auth.go# Verify constant-time implementation
sidedetect check encryption.gopackage main
import (
"fmt"
"github.com/hallucinaut/sidedetect/pkg/sidechannel"
)
func main() {
scanner := sidechannel.NewScanner()
// Analyze source code
sourceCode := `if password == secret { return true }`
vulns := scanner.AnalyzeCode(sourceCode)
fmt.Printf("Found %d vulnerabilities\n", len(vulns))
// Check constant-time
isConstant := sidechannel.ConstantTimeCheck(sourceCode)
fmt.Printf("Constant-time: %v\n", isConstant)
// Calculate risk score
riskScore := sidechannel.CalculateRiskScore(vulns)
fmt.Printf("Risk Score: %.0f%%\n", riskScore)
}| ID | Type | Severity | CVSS | Description |
|---|---|---|---|---|
| TC-001 | Password Comparison | HIGH | 7.5 | Non-constant-time password comparison |
| TC-002 | Secret Indexing | HIGH | 7.0 | Direct array indexing with secret data |
| TC-003 | Secret Branching | MEDIUM | 6.5 | Conditional branching on secret values |
| ID | Type | Severity | CVSS | Description |
|---|---|---|---|---|
| CA-001 | Table Lookup | HIGH | 7.8 | Table lookup with secret index |
| ID | Type | Severity | CVSS | Description |
|---|---|---|---|---|
| BP-001 | Branch Prediction | MEDIUM | 6.0 | Data-dependent branching |
| Score | Status | Action |
|---|---|---|
| 90-100 | Excellent | No issues detected |
| 70-89 | Good | Address medium vulnerabilities |
| 50-69 | Fair | Address high/critical issues |
| <50 | Poor | Immediate remediation required |
# Run all tests
go test ./...
# Run with coverage
go test -cover ./...
# Run specific test
go test -v ./pkg/sidechannel -run TestCheckTimingAttacksScanning: ./myproject
Type: directory
Scan Complete
=============
Side-channel vulnerabilities found: 4
Risk Score: 75%
Vulnerabilities:
[1] HIGH - Timing Attack - Password Comparison
Location: auth.go:15
Description: Non-constant time comparison detected - vulnerable to timing attacks
CVSS: 7.5
Recommendation: Use constant-time comparison functions
[2] HIGH - Cache Timing Attack - Table Lookup
Location: crypto.go:42
Description: Table lookup with secret index - vulnerable to cache timing attacks
CVSS: 7.8
Recommendation: Use constant-time table access
[3] MEDIUM - Timing Attack - Secret Branching
Location: verify.go:28
Description: Conditional branching based on secret data - timing leakage possible
CVSS: 6.5
Recommendation: Use constant-time control flow
[4] MEDIUM - Branch Prediction Attack
Location: sign.go:55
Description: Data-dependent branching - vulnerable to branch prediction attacks
CVSS: 6.0
Recommendation: Use branchless implementations
- Side-channel attacks can bypass traditional security controls
- Timing attacks require precise measurement but are increasingly practical
- Cache attacks work across process boundaries in some scenarios
- Always use constant-time implementations for cryptographic operations
- Use constant-time comparison for secrets (passwords, keys, tokens)
- Avoid table lookups with secret indices in cryptographic operations
- Use branchless implementations when possible for secret-dependent logic
- Employ constant-time crypto libraries like libsodium, Botan
- Regular security audits of cryptographic implementations
sidedetect/
├── cmd/
│ └── sidedetect/
│ └── main.go # CLI entry point
├── pkg/
│ └── sidechannel/
│ ├── sidechannel.go # Side-channel analysis
│ └── sidechannel_test.go # Unit tests
└── README.md
MIT License
- Side-channel security research community
- Constant-time crypto library authors
- Security researchers sharing vulnerability patterns
Built with GPU by hallucinaut