Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does DKIM prevent impersonation?

Tags:

dkim

spoofing

I understand that DKIM can be used to prevent the spoofing of the "From:" header in an email. Email receivers can validate the DKIM-Signature to verify the "From:" header.

    DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; **d=example.com**; 
h=from:to:subject:content-type; **s=smtpapi**; 
bh=Qdu07jaeIipfZPkXZqzhD3HXzeo=; b=skdennE1MwDXUGfm/mox/OF8MJjaq
jrE3ETrbeE4PdvokFigU5qTuf2LJ8M9MmxCm4ji6G+CG4u7eKeCdMgAFgEwZCVhp
8UFYUwXkHFqgzKznGremWWHaXU9aIzUtWyFuOziZhqcP3Jn7/V8xyaCEIPP0dz6b
aaaI87oazVBMp8=
From: CEO <[email protected]>

For instance, in this email header, the DKIM-Signature says to check "smtpapi._domainkey.example.com" for the public key used to sign the email headers.

But couldn't the attacker simply replace the entire DKIM-Signature content to point to another domain that they control, and re-generate the DKIM-Signature with a set of keys that they own? This would create a valid DKIM-Signature, but would allow email spoofing.

DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; **d=attackerDomain.net**; 
h=from:to:subject:content-type; **s=attackerKey**; 
bh=Qdu07jaeIipfZPkXZqzhD3HXzeo=; b=skdennE1MwDXUGfm/mox/OF8MJjaq
jrE3ETrbeE4PdvokFigU5qTuf2LJ8M9MmxCm4ji6G+CG4u7eKeCdMgAFgEwZCVhp
8UFYUwXkHFqgzKznGremWWHaXU9aIzUtWyFuOziZhqcP3Jn7/V8xyaCEIPP0dz6b
aaaI87oazVBMp8=
From: CEO <[email protected]>

Using DKIM, would an email receiver be able to determine that the first email is valid, while the second email is spoofed? How does the email receiver know which DKIM servers are authoritative for the "example.com" domain? (example.com vs attackerDomain.net)

like image 537
InfoBill Avatar asked Dec 20 '25 08:12

InfoBill


1 Answers

If they created a new key pair and point it to their domain, then they would be authenticating on said domain and not the domain they are trying to spoof.

In order for them to spoof a legitimate domain, they would need to obtain your private key. Therefore, signing out on their mail server with the private key.

However, they will not pass SPF authentication because the server they are sending from are not authorized.

When your legitimate mail server sends out mail, it will sign the mail with a crypto signature using your private key. The receiving e-mail servers does a look up on the public key (remember, its your public key that you publish yourself) and validates it.

like image 181
Kadaw Tomtom Avatar answered Dec 21 '25 21:12

Kadaw Tomtom