Skip to main content

fourfifty

python core dependencies status hack club terra

SMTP false negatives bloom filter real emails sent

Fourfifty is an email traffic simulator (for now) and an email rate_limiter (soon™️). It works on probabilistic data structures, bloom filter built but not set up for now.

Status: week 1 of 2(?). The traffic simulator, the exact baseline and the Bloom filter is built. Count-Min sketch and HyperLogLog come next.

Try it

pip install -e ".[plot]"       # [plot] is optional, only needed for --plot
fourfifty                       # 10-minute simulation, prints traffic tables
fourfifty --duration 300 --seed 7
fourfifty --plot                # also saves total.png and recipients.png
python -m pytest                # run the tests
TOTAL MAIL TRAFFIC BY EVENT TYPE
--------------------------------
type            events     share
--------------------------------
normal          14,969     52.5%
harvest          7,554     26.5%
promo            6,000     21.0%
--------------------------------
total           28,523




TOP SENDERS BY DIFFERENT RECIPIENTS
--------------------------------------------
sender                            recipients
--------------------------------------------
bot@harvest.example                    7,249
news@letter.example                    6,000
user4943@sender4943.example              102
user19103@sender19103.example             54
user2816@sender2816.example               43

The harvester and newsletter are the busiest senders, which makes this a challenge for the rate limiter, since it cant go off bursts alone.

What's in it

A traffic simulator with hidden attacks (fourfifty/simulator.py)

Real mail corpus has no answer key of which event is which. A simnulation does, so for the rate_limtier to be scored, traffic needs to be simulated.

Features:

  • 10,000 senders from a pool of 20,000 mailboxes, Zipf-weighted activity
  • every sender has a personal circle of recipients (Pareto-sized, capped at 85% of the pool)
  • traffic types:
    • normal: normal email activity
    • harvest: guesses addresses. around one in five of them are real.
    • retry: a random 3% of normal mail, scheduled out to be sent 5 minutes after
    • promo: a newsletter activity burst
  • reproducible
  • IPs from 198.18.0.0/15 (RFC 2544 benchmarking range) and .example domains

An exact baseline (fourfifty/baseline.py)

the answer key for the rate_limiter

  • emails_per_sender: what Count-Min will estimate
  • recipients_per_sender: what HyperLogLog will estimate
  • valid_mboxes: what the Bloom filter will approximate

A Bloom filter (fourfifty/bloom.py)

answers wether an address is real or not. works quick but has false positives.

  • bytearray bit storage, SHA-256 and double hashing for k positions
  • no false negatives
  • false positive rate with m = 10,000 bits, k = 7, 1,000 items: 0.84% measured vs 0.82% expected from theory

What the traffic looks like

Total mail traffic by type

The harvesting is steady, as expected. the promotion bursts at minutes 3 to 5. and retries start at minute 5

Different recipients per sender

HyperLogLog will catch the gap between normal senders and bulk senders, but it wont differentiate between promo and harvest. thats why bloom is needed.

Roadmap

  • Count-Min sketch (emails per sender)
  • HyperLogLog (different recipients per sender)
  • scoring harness: sketches vs exact baseline
  • more attack types: compromised accounts & bots

Metadata

Release files for fourfifty 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fourfifty 0.1.0
File Size Uploaded Provenance Actions
fourfifty-0.1.0.tar.gz 10.0 kB Without provenance Details for fourfifty-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fourfifty 0.1.0
File Interpreter ABI Platform Actions
fourfifty-0.1.0-py3-none-any.whl Python 3 none any Details for fourfifty-0.1.0-py3-none-any.whl

Total release size: 18.5 kB

Release files / fourfifty-0.1.0.tar.gz

Download URL fourfifty-0.1.0.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
07e0487cf745588ac199df2b38deb9ac964b372a67e2cd80d1ac758b818a5390
BLAKE2b-256 checksum
How to use checksums
cd992bd45d28d6adb566f59868fd4464a027231ef5554280959878b943d31bf2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Release files / fourfifty-0.1.0-py3-none-any.whl

Download URL fourfifty-0.1.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f25fa936878763d5ad738dce9d8980785b3602372dc9243b18670ace1a27ede8
BLAKE2b-256 checksum
How to use checksums
dc256ced6ba992253d8a4b90d57777ea22b0c4da94406b37ea2c01f607e411db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Security for fourfifty 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page