
CVE-2026-8080 DKIM सत्यापन बायपास का Python अनुकरणात्मक प्रदर्शन, जो दर्शाता है कि कैसे गैर-अनुपालक हेडर कैननिकलाइज़ेशन हमलावरों को हेडर इंजेक्ट करने की अनुमति देता है, जबकि हस्ताक्षर सत्यापन फिर भी सफल होता है।
# dkim_verifier_sim.py - Flawed DKIM verifier
import re, hashlib
# Simulated email with DKIM signature
raw_email = b"""From: [email protected]
To: [email protected]
Subject: Hello
DKIM-Signature: v=1; a=rsa-sha256; d=example.com; s=mail; h=from:to:subject;
b=abc123; bh=def456;
X-Extra: injected
This is a test.
"""
def parse_headers(raw):
headers = {}
lines = raw.decode().split('\r\n')
for line in lines:
if ': ' in line:
key, val = line.split(': ', 1)
headers[key.lower()] = val
return headers
def verify_dkim(raw):
headers = parse_headers(raw)
# Vulnerability: canonicalisation does not remove extra headers not in the 'h' list
# According to RFC, only headers listed in 'h' are signed, but the verifier should exclude others.
# Here we simulate that extra header 'x-extra' is mistakenly included in the hash computation
# because the verifier canonicalizes all headers instead of just the listed ones.
signed_headers = headers['dkim-signature'].split('h=')[1].split(';')[0].split(':')
# Build header list for hash
header_block = ""
for h in signed_headers:
header_block += f"{h}:{headers[h]}\r\n"
# Flaw: include extra header X-Extra because it's present in the actual headers
if 'x-extra' in headers:
header_block += f"x-extra:{headers['x-extra']}\r\n"
# Now compute hash and compare... For demo, we'll just print that verification succeeds incorrectly.
print("Verification passed (incorrectly includes extra header)")
verify_dkim(raw_email)
मेल सर्वर का DKIM वेरिफ़ायर RFC 6376 में परिभाषित कैननिकलाइज़ेशन एल्गोरिदम का सख्ती से पालन नहीं करता है। यह हैश गणना में अतिरिक्त हेडर फ़ील्ड शामिल करता है, जिससे हमलावर एक हेडर (जैसे, X-Extra: injected) जोड़ सकता है जो ईमेल के व्यवहार को बदल देता है, जबकि हस्ताक्षर अभी भी सत्यापन में पास हो जाता है।
h= टैग में सूचीबद्ध हेडर के बजाय सभी मौजूदा हेडर को कैननिकलाइज़ करता है, जिससे हस्ताक्षरित और सत्यापित सामग्री में बेमेल उत्पन्न होता है।सिम्युलेटेड त्रुटिपूर्ण वेरिफ़ायर चलाएँ:
python dkim_verifier_sim.py
यह “Verification passed” प्रिंट करता है, भले ही एक अतिरिक्त हेडर जोड़ा गया हो।