CS FundamentalsVery hardProduct-company placement · Security interview
A developer authenticates API messages as tag = SHA-256(secret ‖ message) instead of using HMAC. Why is this unsafe?
- A. SHA-256 is not collision-resistant, so two messages share a tag
- B. The secret can be recovered from the tag by inverting SHA-256
- C. An attacker who knows one message and its tag can compute a valid tag for that message with extra data appended, without the secret
- D. The tag is too short to resist brute force
Correct answer: C. An attacker who knows one message and its tag can compute a valid tag for that message with extra data appended, without the secret
Merkle–Damgård hashes like SHA-256 expose their internal state as the output, so from H(secret ‖ m) one can continue hashing to get H(secret ‖ m ‖ padding ‖ extra): a length-extension attack. HMAC's nested construction blocks this; SHA-256 itself is still collision- and preimage-resistant.
More Computer Networks questions
- Two sites connect through a router that performs NAT. An IPsec tunnel using AH fails, while one using ESP with NAT traversal works. Why?
- Asha sends one email with To: Ravi and Bcc: Meena, both at the same domain. How does Meena's server know to deliver a copy to her, given…
- A stateless packet filter at a campus edge allows all outbound TCP, and allows inbound TCP only when the ACK flag is set (so only replies…
- A company wants its bare domain example.com to point at a hosting provider's name, as www.example.com does with a CNAME. Why does standard…
- How many of these are valid IPv6 addresses? 1. 2001:db8::1:0:0:1 2. 2001:db8::1::5 3. fe80::abcd:12345 4. ::ffff:192.0.2.1 5…
- Host 192.168.1.10/24 with gateway 192.168.1.1 has an empty ARP cache. It pings 8.8.8.8, then 1.1.1.1, then 192.168.1.20. How many ARP…