Page MenuHomeFreeBSD

db/hash: Harden hash(3) database code
ClosedPublic

Authored by bnovkov on Aug 13 2026, 11:12 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Sep 19, 10:31 PM
Unknown Object (File)
Thu, Sep 17, 4:38 AM
Unknown Object (File)
Tue, Sep 15, 11:06 PM
Unknown Object (File)
Tue, Sep 15, 1:41 AM
Unknown Object (File)
Sat, Sep 12, 8:08 AM
Unknown Object (File)
Sat, Sep 12, 7:54 AM
Unknown Object (File)
Fri, Sep 11, 5:37 AM
Unknown Object (File)
Fri, Sep 11, 4:14 AM
Subscribers

Details

Summary

The hash(3) database code does not validate the on-disk database header,
leaving it open to several OOB read and write vulnerabilities.

This change adds basic header validation and array bounds checking to
parts of the hash(3) code that can be manipulated by messing with the
database header.

Sponsored by: Klara, Inc.
MFC after: 1 month

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 76922
Build 73805: arc lint + arc unit

Event Timeline

kevans added inline comments.
lib/libc/db/hash/hash.c
161

This is also signed, are negative values not an issue?

bnovkov added inline comments.
lib/libc/db/hash/hash.c
161

Thanks for catching this, negative values here are an issue.

bnovkov marked an inline comment as done.

Propagate error from bounds checking instead of aborting

This revision is now accepted and ready to land.Thu, Sep 17, 4:29 PM
This revision was automatically updated to reflect the committed changes.