Skip to content

Use constant-time comparison for OMAPI authentication signature#8

Open
kodareef5 wants to merge 2 commits intoisc-projects:masterfrom
kodareef5:fix-omapi-auth-timing
Open

Use constant-time comparison for OMAPI authentication signature#8
kodareef5 wants to merge 2 commits intoisc-projects:masterfrom
kodareef5:fix-omapi-auth-timing

Conversation

@kodareef5
Copy link
Copy Markdown

omapip/protocol.c line 716 verifies OMAPI HMAC-MD5 authentication signatures using memcmp(), which returns early on the first byte mismatch. This leaks timing information about how many bytes of the signature are correct.

Replace with a constant-time XOR accumulation loop that examines all bytes regardless of match position. The volatile qualifier prevents compiler optimization from reintroducing early exit.

Builds clean with -Wall -Werror.

1. common/tree.c: Change new_len from signed int to unsigned int and
   add UINT_MAX/2 check before doubling. Signed int overflow in the
   doubling loop is undefined behavior that could cause infinite loop.

2. common/parse.c: Check universe_max > INT_MAX/2 before doubling the
   option space array.

3. omapip/alloc.c: Check count * sizeof(omapi_addr_t) + sizeof(list)
   does not overflow size_t before allocation.

4. omapip/array.c: Check (max + delta) * sizeof(char *) does not
   overflow size_t before array growth allocation.

5. common/options.c:3664: Check length * 4 + 3 does not overflow
   unsigned int in FQDN option buffer allocation.

6. common/options.c:2738: Check num_opts * 2 does not overflow int
   in server ORO buffer allocation.
The OMAPI protocol verifies HMAC-MD5 authentication signatures
using memcmp(), which returns early on the first byte mismatch.
This leaks timing information about how many bytes of the
signature are correct, enabling a timing side-channel attack
against the OMAPI management interface.

Replace with a constant-time XOR accumulation loop that examines
all bytes regardless of match position.
@fxdupont
Copy link
Copy Markdown
Contributor

Please use isc_safe_memequal which was added many years ago to solve this issue in BIND.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants