Git Product home page Git Product logo

mkspf's Introduction

mkspf

script to expand/flatten SPF records

The problem

RFC7208 defines a 10-query limit for clients, upon which they will fail open. With increased delegation (via the include: mechanism) to various cloud services, the useful scalability of SPF is questionable. The very act of delegating control over SPF in this way, allows a third party to (intentionally or accidentally) break SPF for your domain by, for example, including multiple levels of SPF that cause you to exceed the limit of 10 DNS lookups.

A solution

This script will walk through all the include/a/mx directives in a seed TXT record, along with any local ip4 and ip6 directives, and build a local list of all the network blocks, formatted for inclusion in a zone file.

Installation

Consists of a single perl script intended to be run via a commit-hook on the DNS repository (or manually, if desired).

Usage

Provide name of the zone file (assumed to be same as domain name) as only argument on the commandline. Script will search for a 'mkspf' TXT record and output a file for inclusion in the main zone.

$ mkspf.pl ~/dns/bind/namedb/example.com

Enter something like this in the example.com zonefile:

@               IN      TXT     "v=spf1 redirect=_spf.example.com"
$INCLUDE _spf.example.com
mkspf           IN      TXT     ("v=spf1"
                                " mx"
                                " ip4:192.0.2.0/24" ; comment
                                " include:example.org include:example.net"
                                " ~all")

Response size considerations

Initially, the script was limited to building a single <256 character string for each TXT record. RFC4408 details a way to supply multiple <256 character strings in a single TXT record in order to return more data per RR and still be under the 10-query limit. The RFC states that "If a published record contains multiple strings, then the record MUST be treated as if those strings are concatenated together without adding spaces."

Of course, we then have to consider limiting to total size so that the response would be <512 byte UDP limit, to avoid failover to (often-filtered) TCP with non-EDNS0-capable clients. See this summary for how we estimate the maximum size for the TXT data.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

History

  • initial commit
  • README edits
  • support multiple strings per TXT RR

Credits

Inspiration from other projects:

License

GNU GPL

mkspf's People

Contributors

oasys avatar rolandrosenfeld avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.