
CVE-2026-8080 DKIM 검증 우회를 시뮬레이션하는 Python 데모로, 비준수 헤더 정규화(non-compliant header canonicalization)가 서명 검증이 여전히 통과되는 동안 공격자가 헤더를 주입할 수 있게 하는 방식을 보여줍니다.
# 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”를 출력합니다.