-
Notifications
You must be signed in to change notification settings - Fork 218
Fix circular SPF reference detection (A→B→A loops) #1398
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
base: main
Are you sure you want to change the base?
Conversation
The existing self-reference checks only caught direct loops (A→A) but missed indirect circular references like A→B→A or longer chains. Added a -Visited parameter to track all domains in the resolution chain. Before recursing into an include or redirect, the function now checks if the target domain has already been visited in the current resolution path. - Direct self-references return specific messages (e.g., "Self-referencing SPF include") - Indirect circular references return "Circular SPF reference detected" Tested against oldmomutual.com which has a circular include with oldmissourimutual.com. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes circular SPF reference detection by introducing a tracking mechanism for visited domains during SPF record resolution. Previously, only direct self-references (A→A) were detected, but indirect circular references (A→B→A) caused infinite loops and stack overflows.
Key changes:
- Added a
$Visitedparameter array to track all domains in the resolution chain - Updated circular reference detection logic for both redirect and include directives
- Distinguished between direct self-references and indirect circular references in error messages
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Accepted Copilot's suggestions, they make sense. |
OK, cool. I didn't have a chance to test yet, so I just kicked off the Copilot review. |
|
A little bump on this @SamErde. We're seeing this is production for quite a few tenants so would love to get the fix in place soon. |
Description
The existing self-reference checks only caught direct loops (A→A) but missed indirect circular references like A→B→A or longer chains. This causes infinite loops which eventually result in a stack overflow.
Added a -Visited parameter to track all domains in the resolution chain. Before recursing into an include or redirect, the function now checks if the target domain has already been visited in the current resolution path.
Tested against oldmomutual.com which has a circular include with oldmissourimutual.com.
Contribution Checklist
Before submitting this PR, please confirm you have completed the following:
/powershell/tests/pester.ps1on your local system.