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

Get-SPFRecord fails on multiple line returned #21

Closed
ChrisOD-AD opened this issue May 23, 2022 · 7 comments · Fixed by #25
Closed

Get-SPFRecord fails on multiple line returned #21

ChrisOD-AD opened this issue May 23, 2022 · 7 comments · Fixed by #25
Assignees
Labels
bug Something isn't working

Comments

@ChrisOD-AD
Copy link

I have a minor change to Get-SPFRecord that fixes the behaviour if a zone has a LONG SPF record.

Changes:

    $SPF = $SPF -join ""
    $spfCnt = ([regex]::Matches($SPF, "v=spf1" )).count
    if ($SPF -eq $null) {
        $SpfAdvisory = "Domain does not have an SPF record. To prevent abuse of this domain, please add an SPF record to it."
    }
    if($spfCnt -gt 1) {
        $SpfAdvisory = "Domain has more than one SPF-record. One SPF record for one domain. This is explicitly defined in RFC4408"
    }
    Else {
        switch -Regex ($SPF) {
            '~all' {
                $SpfAdvisory = "An SPF-record is configured but the policy is not sufficiently strict."
            }
            '-all' {
                $SpfAdvisory = "An SPF-record is configured and the policy is sufficiently strict."
            }
            "\?all" {
                $SpfAdvisory = "Your domain has a valid SPF record but your policy is not effective enough."
            }
            '\+all' {
                $SpfAdvisory = "Your domain has a valid SPF record but your policy is not effective enough."
            }
            Default {
                $SpfAdvisory = "No qualifier found. Your domain has a SPF record but your policy is not effective enough."
            }
        }
    }
@T13nn3s
Copy link
Owner

T13nn3s commented May 30, 2022

Hi ChrisOD-AD,
Do you have a specific example so that I can validate the current behavior and the behavior after the change?

@ChrisOD-AD
Copy link
Author

ChrisOD-AD commented May 30, 2022 via email

@T13nn3s T13nn3s self-assigned this May 30, 2022
@T13nn3s T13nn3s added the bug Something isn't working label May 30, 2022
@T13nn3s
Copy link
Owner

T13nn3s commented May 30, 2022

Thanks. I can confirm that the output of the script does not reflect the reality of the SPF record. I now see it as a bug in the script and am doing some further research. The SPF record is indeed very long and also contains errors (too many DNS lookups).

Your suggested change doesn't seem to be the solution yet. I need to look into this further.

@ChrisOD-AD
Copy link
Author

ChrisOD-AD commented May 30, 2022 via email

@ChrisOD-AD
Copy link
Author

ChrisOD-AD commented Oct 11, 2022 via email

@T13nn3s
Copy link
Owner

T13nn3s commented Nov 2, 2022

@ChrisOD-AD,

I have tried to solve this 'problem' in the script, but am so far unsuccessful in doing so.

An SPF record may contain a maximum of 255 characters. Go over this limit, the SPF record is returned to the script as an array. Furthermore, an SPF record above 255 characters may not be validated correctly, which may result in an incorrect check and then the SPF record no longer functions properly.

My advice is to split your SPF records into multiple TXT records and then create 1 SPF record into which you include the other records.

So far, I can't get this fixed neatly in the script and I'll leave it as it is for now.

@T13nn3s T13nn3s closed this as not planned Won't fix, can't repro, duplicate, stale Nov 2, 2022
@ChrisOD-AD
Copy link
Author

ChrisOD-AD commented Nov 2, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants