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

Unable to parse long SPF record strings (>255 characters) #2

Open
phyber opened this issue Apr 5, 2024 · 4 comments
Open

Unable to parse long SPF record strings (>255 characters) #2

phyber opened this issue Apr 5, 2024 · 4 comments
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@phyber
Copy link

phyber commented Apr 5, 2024

Hi,

I'm attempting to parse an SPF record that is longer than 255 characters which results which in a SourceLengthExceeded error.

I'm not sure this error should be triggered here. RFC 7208 section 3.3 says:

   TXT records containing multiple strings are useful in constructing
   records that would exceed the 255-octet maximum length of a
   character-string within a single TXT record.

I'm guessing that the TXT record length limit is where the 255 number comes from, but section 3.4 says:

3.4  Record Size

   The published SPF record for a given domain name SHOULD remain small
   enough that the results of a query for it will fit within 512 octets.
   Otherwise, there is a possibility of exceeding a DNS protocol limit.

It feels like the string length here should be increased to at least 512 characters, even then, it's only a SHOULD and some DNS implementations could be returning more characters.

Does a length check need to exist here at all? Perhaps a warning about the potential record lengths in the documentation is enough, with links to what the RFC has to say on the matter.

@Bas-Man
Copy link
Owner

Bas-Man commented Apr 5, 2024

Hi,

Yes. I think you are correct. I have been thinking this needed to be changed.
Take a look at the dev branch if you want to submit a pull request.

Note that there are big changes coming.

I am in the process of moving through current SPF Struct to SpfBuilder and a leaner simpler Spf Struct is being added.

Will have support to iterate over the mechanism types. As well as covert Spf into a Spfbuilder.

Current away. So I will look at the change in a day or two.

@Bas-Man
Copy link
Owner

Bas-Man commented Apr 5, 2024

Also if you could leave the sample sod record. I will add it as a test case.

@Bas-Man
Copy link
Owner

Bas-Man commented Apr 8, 2024

@phyber
I have pushed a possible v0.2.7 version to github. Please test with this code and let me know how it goes.

https://github.com/Bas-Man/rust-decon-spf/tree/v0.2.7.candidate

@Bas-Man
Copy link
Owner

Bas-Man commented Apr 8, 2024

You might be right. Might be worth relaxing the rule. I will see if I can do something along these lines with version 0.3.0.

@Bas-Man Bas-Man self-assigned this Apr 10, 2024
@Bas-Man Bas-Man added bug Something isn't working documentation Improvements or additions to documentation labels Apr 10, 2024
Bas-Man added a commit that referenced this issue Nov 8, 2024
Based on Issue #2. I have increased MAX_SPF_STRING_LENGTH from 255
to 512.

I will also consider making this simply a warning in the documentation
if not in actual code.

chore(error): Update error string for MAX_SPF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants