Skip to content

fix: add TXT record size guard (CVE-2026-48045) - #1809

Open
alor29 wants to merge 1 commit into
python-zeroconf:masterfrom
alor29:fix-txt-record-limit
Open

fix: add TXT record size guard (CVE-2026-48045)#1809
alor29 wants to merge 1 commit into
python-zeroconf:masterfrom
alor29:fix-txt-record-limit

Conversation

@alor29

@alor29 alor29 commented Jul 12, 2026

Copy link
Copy Markdown

Summary

This PR adds explicit guards to ServiceInfo to prevent oversized DNS TXT records from causing memory exhaustion or crashes. DNS TXT entries are limited to 255 bytes, but previously the code attempted to encode arbitrary lengths, resulting in ValueError: bytes must be in range(0, 256).

Changes

  • Added a guard in ServiceInfo.__init__ to reject property values longer than 255 bytes.
  • Added a guard in _set_properties to reject key=value records longer than 255 bytes before encoding.
  • Ensures only valid TXT records are passed to the encoder.

Proof of Fix

  • Before fix (poc_bad.py):
zeroconfPOC1 [poc_bad.py](https://github.com/user-attachments/files/29945043/poc_bad.py) - **After fix (poc_good.py):** [poc_good.py](https://github.com/user-attachments/files/29945052/poc_good.py) zeroPOC4

Impact

This resolves CVE‑2026‑48045 (memory exhaustion via oversized TXT records) and ensures compliance with DNS TXT record limits. It prevents crashes and uncontrolled resource usage when handling malformed inputs.
zeroconfPOC3

@alor29 alor29 changed the title Add TXT record size guard to prevent memory exhaustion (CVE-2026-48045) fix: add TXT record size guard (CVE-2026-48045) Jul 12, 2026
@alor29
alor29 force-pushed the fix-txt-record-limit branch 2 times, most recently from a12e298 to 8ccc0f2 Compare July 12, 2026 20:25
@alor29
alor29 force-pushed the fix-txt-record-limit branch from 8ccc0f2 to 0ece3f1 Compare July 13, 2026 11:53
@hartwork

Copy link
Copy Markdown

For the record, pull request #1751 claims to have fixed CVE-2026-48045.

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