Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update: fix dkim extraction from TXT records for some domains #25

Conversation

vishal-android-freak
Copy link

Weirdly for some TXT record answers, the TXT record string has a \\" before the DKIM prefix because of which an empty string was returned. This tries to remove the escape characters and correctly read the DKIM record

Weirdly for some TXT record answers, the TXT record string has a `\\"` before the DKIM prefix because of which an empty string was returned. This tries to remove the escape characters and correctly read the DKIM record
@wolveix wolveix self-requested a review November 8, 2024 12:35
@wolveix wolveix marked this pull request as draft November 8, 2024 12:36
@vishal-android-freak
Copy link
Author

The changes are completed and ready for review now :)

@vishal-android-freak vishal-android-freak marked this pull request as ready for review November 8, 2024 12:37
@wolveix
Copy link
Member

wolveix commented Nov 8, 2024

@vishal-android-freak thanks for the contribution! I'll give this a look over :) Do you have a domain that you can provide that exhibits the problematic behaviour before your changes, please?

@vishal-android-freak
Copy link
Author

vishal-android-freak commented Nov 8, 2024

Yes, it is my company's domain itself - https://rudrasecure.com

The extracted TXT record has a \\"v1= at the start and \\; at the end of the DKIM part

@wolveix
Copy link
Member

wolveix commented Nov 8, 2024

@vishal-android-freak what DKIM selector does your domain use? I'm not currently seeing a DKIM record with our default list :D

@vishal-android-freak
Copy link
Author

Ah yes, I pass the dkimSelector as default

@wolveix
Copy link
Member

wolveix commented Nov 8, 2024

@vishal-android-freak yep, and which selector do you provide? Could you provide me with the scan command you're running? E.g. ./dss scan yourdomain.tld --dkimSelector x

@vishal-android-freak
Copy link
Author

This is what I am running

dss scan --dkimSelector default rudrasecure.com

@wolveix
Copy link
Member

wolveix commented Nov 8, 2024

Thanks!

@wolveix
Copy link
Member

wolveix commented Nov 8, 2024

@vishal-android-freak after inspecting your domain directly, it seems that this is actually a misconfiguration issue. Here's the raw dig output from our globalcyberalliance.org domain:

~
❯ dig gca._domainkey.globalcyberalliance.org txt

; <<>> DiG 9.10.6 <<>> gca._domainkey.globalcyberalliance.org txt
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 36909
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;gca._domainkey.globalcyberalliance.org.        IN TXT

;; ANSWER SECTION:
gca._domainkey.globalcyberalliance.org. 300 IN TXT "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCqPnV7+e5SuK77YHtzO815h/qofRr/ZCnCzER9CnHQX3HXfmVrhWoCMG6p4HpWVN1uZhsuqMdeOtwzh4DCvlb2D7BDoQAbTUdb9tEZ1sY4pOqUgYfjVLmJXztN8HfLj2fbqvOZEnUPNNHb4RGouSFUBpLsTMTCodIfF/xSZfGNZQIDAQAB"

And here's the raw dig output from your domain:

~
❯ dig default._domainkey.rudrasecure.com txt    

; <<>> DiG 9.10.6 <<>> default._domainkey.rudrasecure.com txt
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5449
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;default._domainkey.rudrasecure.com. IN TXT

;; ANSWER SECTION:
default._domainkey.rudrasecure.com. 3483 IN TXT "\"v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAypzx5jyJoi0C8heUJfP8M8CIWKTtJCAv6fRTqJ8+9XE9Skv4ultwE7Pyp+Fe7r4waq0bgjdpQe+uRRzi2qyXrhhbKXYOlk0ZtCNH4SN0aL5Y5Ldn2tlvdhnBH7kiLfd2g8bzjTWd0mv8jkopO647f9GAdx0fTnAZ0AySrrtEX46RNX/nlblzHJDJjPetrC5/" "C\" m3yfpQ+2qNp3lSXFtdtIH4uP+v0Jr13307L/zYEl0uwxNAv8DCugTZcos39p9qRkKKqjiOT9iy8rphkxTZw3RPrPoVbp9ZKaiHoBJxx1+c4D4wLd8Ingh/q3mFJ99q5BVsBmr5RKlFjRLdOSD2tswIDAQAB\\;"

Your record itself contains backslashes. I'm assuming when you added the DNS record to your provider, you left the quotes intact, and then your DNS provider automatically escaped them when creating the record.

@wolveix wolveix closed this Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants