You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Modern CPUs include SHA-NI (SHA New Instructions) that accelerate SHA-256:
Platform SHA-256 Throughput SHA-NI Available
Intel (Sunny Cove+) ~2,000 MB/s Yes (since Ice Lake, 2019)
AMD (Zen+) ~2,500 MB/s Yes (since Zen, 2017)
Apple (M1+) ~3,000 MB/s Yes (ARMv8 SHA extensions)
Fallback (no SHA-NI) ~400 MB/s No (software only)
Python's hashlib automatically uses hardware acceleration when available via OpenSSL.
4. Attack Scenarios & Mitigations
4.1 Scenario: Compromised CDN
Attack: CDN edge server returns modified file content
Detection: SHA-256 hash of downloaded chunk ≠ expected hash
Mitigation:
1. Per-chunk hash catches modification immediately
2. Chunk is marked FAILED and re-downloaded
3. If CDN consistently returns bad data, chunk is ABANDONED after max retries
4. User is notified of persistent integrity failure
5. Whole-file hash provides final verification after assembly
Prerequisite: User must provide expected_hash from a trusted source
(not from the same CDN that serves the file)
4.2 Scenario: Network Bit Flip
Attack: Random bit error during transit (RAM error, noisy link)
Detection: SHA-256 of received bytes ≠ expected hash
Mitigation:
1. Even a single bit flip changes the SHA-256 hash completely (avalanche effect)
2. Chunk is automatically re-downloaded
3. TCP checksums catch most transport errors, SHA-256 catches the rest
4.3 Scenario: State File Tampering
Attack: Attacker modifies state file to mark all chunks as COMPLETE
without actually downloading them
Detection:
1. Chunk files don't exist on disk → re-download triggered
2. Chunk files exist but wrong size → re-download triggered
3. Whole-file hash verification catches any assembly from bad chunks
Mitigation:
1. State file permissions (0600) prevent unauthorized writes
2. Assembly re-verifies each chunk hash
3. Whole-file hash is final gate
4.4 Scenario: Malicious Redirect
Attack: Server redirects HTTP→HTTPS to a malicious server
Detection:
1. TLS certificate verification catches domain mismatch
2. HTTPS→HTTP downgrade redirect is blocked
3. Final hash verification catches content substitution
Mitigation:
1. Certificate verification enabled by default
2. HTTPS downgrade protection
3. Expected hash comparison (user-provided)
5. Security Checklist for Operators
Always use HTTPS URLs (not HTTP)
Always provide --hash from a trusted source (not the download server itself)
Keep Python and OpenSSL updated for latest TLS/hash support
Restrict file permissions on download directories
Review logs for persistent integrity failures (may indicate active attack)
Use verify_ssl: true in configuration (default)
Do not store authentication tokens in config files (use environment variables)
Monitor for unusual retry rates (may indicate network-level attack)
6. Compliance Notes
Standard
Relevance
ChunkGuard Compliance
FIPS 140-2
Cryptographic module validation
Uses Python hashlib backed by OpenSSL (FIPS-validated builds available)