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

Set up SPF records to prevent spoofing #158

Open
amcl61 opened this issue Aug 18, 2022 · 3 comments
Open

Set up SPF records to prevent spoofing #158

amcl61 opened this issue Aug 18, 2022 · 3 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@amcl61
Copy link

amcl61 commented Aug 18, 2022

Hello,

Our report is showing 5 subdomains with "Is Hardfail" set to "Not Detected". I've confirmed using Kitterman that they are all set with v=spf1 -all.
I should also mention these 5 domains are not messaging domains.

Regards,

Anne

@JManDoo
Copy link

JManDoo commented Sep 29, 2022

In the check-ORCA235.ps1

The code is checking for an "Uncommon" redirect only
The code should find the standard spf record, which is listed in the report and stored in $SPF

I think the problem is if you exceed the TXT Record length of 255 chars, then the actual record is returned as an Array!
Sooo, here is the fix since ours does exceed 255 chars Information on Concatenating TXT Records

....
             # Check objects
                $ConfigObject = [ORCACheckConfig]::new()
                $ConfigObject.Object = $($AcceptedDomain.Name)

                $SPF = Resolve-DnsName -Name $($AcceptedDomain.Name) -Type TXT @SplatParameters | where-object { $_.strings -match "v=spf1" } | Select-Object -ExpandProperty strings -ErrorAction SilentlyContinue
                
				if ($SPF -match "redirect") {
                    $redirect = $SPF.Split(" ")
                    $RedirectName = $redirect -match "redirect" -replace "redirect="
                    $SPF = Resolve-DnsName -Name "$RedirectName" -Type TXT @SplatParameters | where-object { $_.strings -match "v=spf1" } | Select-Object -ExpandProperty strings -ErrorAction SilentlyContinue
                }
                #BEGIN NEW CODE HERE
                Else{
                    $FlatSPF = $Null
                    if ($SPF -is [array]) {
                        # SPF Record is over 255 chars, we need to flatten it for the test
                        ForEach($SPFRecord in $SPF){
                            $FlatSPF = $FlatSPF + $SPFRecord
                        }
                    }
                    $SPF = $FlatSPF
                }
                #END OF NEW CODE

                $SpfAdvisory = "No SPF record"
                if ( $null -eq $SPF) {
                    $SpfAdvisory = "No SPF record"
                }
                if ($SPF -is [array]) {
                    $SpfAdvisory = "More than one SPF-record"
                }
                Else {
                    switch -Regex ($SPF) {
                    '~all' {
                        $SpfAdvisory = "Soft Fail"
                    }
                    '-all' {
                        $SpfAdvisory = "Hard Fail"
                    }
                    Default {
                        $SpfAdvisory = "No qualifier found"
                    }
                }
                }
....

@cammurray
Copy link
Owner

Putting in vnext bucket where i'll put a bit of focus on the sender auth checks, it wont make 2.3 because I need to get it out the door to fix some big issues.

@cammurray cammurray added this to the vnext milestone Jun 8, 2023
@cammurray cammurray added the bug Something isn't working label Jun 8, 2023
@cammurray cammurray modified the milestones: vnext, 2.7 Nov 15, 2023
@cammurray
Copy link
Owner

I'd rather do this one properly and that's slightly more complicated than I thought. I'm going to push this to 2.8 so I can get a bunch of low hanging fruit out in 2.7.

@cammurray cammurray modified the milestones: 2.7, 2.8 Nov 16, 2023
@cammurray cammurray self-assigned this Nov 29, 2023
@cammurray cammurray modified the milestones: 2.8, 2.8.1 Nov 30, 2023
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

No branches or pull requests

3 participants