[PR #2057] [MERGED] proto/rr: do not deserialize ClientSubnets with invalid prefixes #2785

Closed
opened 2026-03-16 11:08:11 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hickory-dns/hickory-dns/pull/2057
Author: @00xc
Created: 10/11/2023
Status: Merged
Merged: 10/12/2023
Merged by: @djc

Base: mainHead: proto/rr/clientsubnet


📝 Commits (1)

  • 256d74a proto/rr: do not deserialize ClientSubnets with invalid prefixes

📊 Changes

1 file changed (+6 additions, -0 deletions)

View changed files

📝 crates/proto/src/rr/rdata/opt.rs (+6 -0)

📄 Description

When serializing a ClientSubnet, if the source prefix is larger than the address itself, we return an error. However, when deserializing the same type we will happily take an invalid prefix. Fix this consistency issue by rejecting invalid prefixes during deserialization.

Before, this would cause the following fuzzing harness to fail, given the appropriate input:

#![no_main]

use libfuzzer_sys::fuzz_target;
use trust_dns_proto::rr::rdata::opt::ClientSubnet;
use trust_dns_proto::serialize::binary::BinDecodable;
use trust_dns_proto::serialize::binary::BinEncodable;

fuzz_target!(|data: &[u8]| {
    if let Ok(net) = ClientSubnet::from_bytes(data) {
        net.to_bytes().unwrap();
    }
});

This would also impact (de)serialization of other types which embed ClientSubnets.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hickory-dns/hickory-dns/pull/2057 **Author:** [@00xc](https://github.com/00xc) **Created:** 10/11/2023 **Status:** ✅ Merged **Merged:** 10/12/2023 **Merged by:** [@djc](https://github.com/djc) **Base:** `main` ← **Head:** `proto/rr/clientsubnet` --- ### 📝 Commits (1) - [`256d74a`](https://github.com/hickory-dns/hickory-dns/commit/256d74a0ba60be037f508e275521fc8e431454df) proto/rr: do not deserialize ClientSubnets with invalid prefixes ### 📊 Changes **1 file changed** (+6 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/proto/src/rr/rdata/opt.rs` (+6 -0) </details> ### 📄 Description When serializing a `ClientSubnet`, if the source prefix is larger than the address itself, we return an error. However, when deserializing the same type we will happily take an invalid prefix. Fix this consistency issue by rejecting invalid prefixes during deserialization. Before, this would cause the following fuzzing harness to fail, given the appropriate input: ```rust #![no_main] use libfuzzer_sys::fuzz_target; use trust_dns_proto::rr::rdata::opt::ClientSubnet; use trust_dns_proto::serialize::binary::BinDecodable; use trust_dns_proto::serialize::binary::BinEncodable; fuzz_target!(|data: &[u8]| { if let Ok(net) = ClientSubnet::from_bytes(data) { net.to_bytes().unwrap(); } }); ``` This would also impact (de)serialization of other types which embed `ClientSubnet`s. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-16 11:08:11 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#2785
No description provided.