#!/usr/bin/env python3 """Recalculates the figures in the Circuit Times bug bounty guide from the published evidence files. python3 bug_bounty_analysis.py frozen mode: verifies each evidence file's SHA-256 hash, recalculates every figure and compares it with the article python3 bug_bounty_analysis.py --live recalculates from whatever evidence files are in this folder, without hash or figure comparison. This mode collects nothing. Run collect.py first to gather fresh files. Frozen mode proves that the files are the ones the article used and that the arithmetic is right. It cannot prove that the original network collection was complete or representative. The checks use explicit raises, so "python3 -O" does not switch them off. """ import collections import datetime as dt import hashlib import json import pathlib import re import statistics import sys import urllib.parse HERE = pathlib.Path(__file__).resolve().parent LIVE = "--live" in sys.argv[1:] EXPECTED_HASHES = { "survey-raw.json": "fce536a8b84bf8e8dabcf5a8d39695cb2fa119e7968c6455fb73a12a76f82201", "hackerone-programs.json": "01f8a6daf1ea629d63989388249d146e181eeb81e5633763825ccc9ea7580296", "bugcrowd-engagements.json": "72d580cb8276d8131f9a1858f0cf49b17ff0044ea48d4235d13644c649015cbc", "intigriti-programs.json": "767ac1f5d6da00ab7f1ae0d7e906ba0bcd6d1b6a8562a29c08de2847b7e8fd27", "yeswehack-programs.json": "fe60c395796f1d3d173b96fe323250bccf1d9010cf7c2eafa81e628c1daa93de", "diodb-program-list.json": "6021b8bacbabea51f99f2cea995f6fb6887d5414d43a047ccb398d2a30366cf1" } PLATFORMS = ("hackerone", "bugcrowd", "intigriti", "yeswehack", "hackenproof", "synack") FIELD_NAMES = ("Contact", "Expires", "Policy", "Acknowledgments", "Preferred-Languages", "Canonical", "Encryption", "Hiring", "CSAF") FIELD = re.compile(r"^(" + "|".join(FIELD_NAMES) + r")[ \t]*:[ \t]*(\S.*)$", re.I | re.M) RFC3339 = re.compile(r"^(\d{4})-(\d\d)-(\d\d)[Tt](\d\d):(\d\d):(\d\d)(\.\d+)?([Zz]|[+-]\d\d:\d\d)$") # Phrases that the survey network's own gateway returns when it refuses a host. A reply holding # one of them did not come from the surveyed site. # Every leap second so far was inserted at 23:59:60 UTC on one of these dates (IERS Bulletin C). # A ":60" second is valid only at one of these instants. Future leap seconds cannot be known. LEAP_SECOND_DATES = frozenset( [(year, 6, 30) for year in (1972, 1981, 1982, 1983, 1985, 1992, 1993, 1994, 1997, 2012, 2015)] + [(year, 12, 31) for year in (1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1987, 1989, 1990, 1995, 1998, 2005, 2008, 2016)]) GATEWAY_REFUSALS = ("is not enabled for this session", "sessions are bound to their configured repositories") class CheckFailed(RuntimeError): pass def load(name): path = HERE / name if not path.is_file(): raise CheckFailed(f"evidence file missing: {name}") blob = path.read_bytes() digest = hashlib.sha256(blob).hexdigest() if not LIVE and digest != EXPECTED_HASHES[name]: raise CheckFailed(f"{name} is not the published file: expected {EXPECTED_HASHES[name]}, got {digest}") try: return json.loads(blob) except ValueError as exc: raise CheckFailed(f"{name} is not valid JSON: {exc}") from None def share(part, whole, digits=1): return f"{part / whole * 100:.{digits}f}%" def media_type(header): """Content-Type without parameters: 'Text/Plain; charset=utf-8' gives 'text/plain'.""" return header.split(";", 1)[0].strip().lower() def parse_expires(value): """Return an aware datetime for a valid RFC 3339 date-time, else None.""" match = RFC3339.match(value.strip()) if not match: return None year, month, day, hour, minute, second = (int(match.group(i)) for i in range(1, 7)) zone = match.group(8) if zone in "Zz": offset = dt.timedelta(0) else: zone_hours, zone_minutes = int(zone[1:3]), int(zone[4:6]) if zone_hours > 23 or zone_minutes > 59: return None offset = dt.timedelta(hours=zone_hours, minutes=zone_minutes) * (1 if zone[0] == "+" else -1) if second > 60: return None fraction = int((match.group(7) or ".0")[1:7].ljust(6, "0")) try: # Build the instant with second 59 when the text says 60, then check that it really is a leap second. moment = dt.datetime(year, month, day, hour, minute, min(second, 59), fraction, tzinfo=dt.timezone(offset)) except ValueError: return None if second == 60: utc = moment.astimezone(dt.timezone.utc) if (utc.hour, utc.minute) != (23, 59) or (utc.year, utc.month, utc.day) not in LEAP_SECOND_DATES: return None moment += dt.timedelta(seconds=1) # the leap second itself, placed at the following midnight UTC return moment def one_year_after(moment): """The same calendar date one year later. February 29 maps to February 28.""" try: return moment.replace(year=moment.year + 1) except ValueError: return moment.replace(year=moment.year + 1, day=28) def self_test(): """The validators must behave on known cases before any figure is trusted.""" good = ("2027-06-30T23:59:59Z", "2027-06-30t23:59:59z", "2027-06-30T23:59:59.25+02:00", "2028-02-29T00:00:00-08:00", "2016-12-31T23:59:60Z", "2017-01-01T00:59:60+01:00") bad = ("2027-06-30", "2027-06-30 23:59:59Z", "2027-02-30T00:00:00Z", "2027-13-01T00:00:00Z", "2027-06-30T24:00:00Z", "2027-06-30T23:59:59", "2027-06-30T23:59:59+25:00", "Wed, 30 Jun 2027 23:59:59 GMT", "2027-06-30T23:59:59+0200", "", "2027-06-30T12:00:60Z", "2027-12-31T23:59:60Z", "2016-12-31T23:59:61Z", "2016-12-30T23:59:60Z") for value in good: if parse_expires(value) is None: raise CheckFailed(f"self-test: valid date rejected: {value!r}") for value in bad: if parse_expires(value) is not None: raise CheckFailed(f"self-test: invalid date accepted: {value!r}") cases = {"text/plain": True, "Text/Plain; charset=utf-8": True, "text/plain-invalid": False, "text/html": False, "": False, "application/octet-stream": False} for header, wanted in cases.items(): if (media_type(header) == "text/plain") != wanted: raise CheckFailed(f"self-test: content type misjudged: {header!r}") start = dt.datetime(2026, 11, 19, 7, 0, tzinfo=dt.timezone.utc) leap_day = dt.datetime(2028, 2, 29, 7, 0, tzinfo=dt.timezone.utc) if one_year_after(start) != dt.datetime(2027, 11, 19, 7, 0, tzinfo=dt.timezone.utc): raise CheckFailed("self-test: one-year rule wrong for an ordinary date") if one_year_after(leap_day) != dt.datetime(2029, 2, 28, 7, 0, tzinfo=dt.timezone.utc): raise CheckFailed("self-test: one-year rule wrong for February 29") if parse_expires("2016-12-31T23:59:60Z") != dt.datetime(2017, 1, 1, tzinfo=dt.timezone.utc): raise CheckFailed("self-test: leap second not placed at the following midnight") if abs(sum(s for s, _ in REWARD_MIX.values()) - 1) > 1e-9: raise CheckFailed("self-test: reward mix shares do not add up to 1") return len(good) + len(bad) + len(cases) + 4 def parse_file(body): fields = collections.defaultdict(list) for raw_name, value in FIELD.findall(body): name = next(n for n in FIELD_NAMES if n.lower() == raw_name.lower()) fields[name].append(value.strip()) return fields def looks_like_html(body): head = body.lstrip()[:300].lower() return head.startswith("<") or " 0 for f in files) fig["found at the well-known path, only at the legacy path"] = (at_well_known, found - at_well_known) fig["served as text/plain, as something else"] = (plain, found - plain) fig["files reached after a redirect"] = redirected fig["qualifying files cut off by the read cap"] = sum(bool(f["attempt"].get("body_truncated")) for f in files) missing = repeated = malformed = expired = valid = far = passed = 0 for f in files: values = f["fields"].get("Expires", []) plain_text = media_type(f["attempt"]["content_type"]) == "text/plain" if not values: missing += 1 continue repeated += len(values) > 1 moment = parse_expires(values[0]) if moment is None: malformed += 1 continue if moment < reference: expired += 1 continue valid += 1 far += moment >= one_year_after(reference) passed += len(values) == 1 and plain_text fig["Expires missing"] = (missing, share(missing, found)) fig["Expires not a valid RFC 3339 date-time"] = (malformed, share(malformed, found)) fig["Expires in the past"] = (expired, share(expired, found)) fig["Expires valid and in the future"] = (valid, share(valid, found)) fig["of those, on or after the one-year anniversary of the survey"] = (far, share(far, found)) fig["Expires listed more than once"] = repeated fig["passed the four selected checks"] = (passed, share(passed, found), share(passed, total)) for name in ("Policy", "Preferred-Languages", "Hiring", "Canonical", "Encryption", "Acknowledgments", "CSAF"): count = sum(name in f["fields"] for f in files) fig[f"field {name}"] = (count, share(count, found, 0)) signed = sum("-----BEGIN PGP SIGNED MESSAGE-----" in f["attempt"]["body"] for f in files) fig["OpenPGP cleartext signature"] = (signed, share(signed, found, 0)) fig["Contact with mailto, Contact with https"] = ( sum(any(v.lower().startswith("mailto:") for v in f["fields"]["Contact"]) for f in files), sum(any(v.lower().startswith("https://") for v in f["fields"]["Contact"]) for f in files)) def text_of(f): return " ".join(v for values in f["fields"].values() for v in values).lower() word = sum("bounty" in text_of(f) for f in files) named = sum(any(p in text_of(f) for p in PLATFORMS) for f in files) either = sum("bounty" in text_of(f) or any(p in text_of(f) for p in PLATFORMS) for f in files) fig["field values with the word bounty"] = (word, share(word, found, 0)) fig["field values naming one of six platforms"] = (named, share(named, found, 0)) fig["either signal"] = (either, share(either, found, 0)) fig["files naming each platform"] = {p: sum(p in text_of(f) for f in files) for p in PLATFORMS} hosts = collections.Counter(urllib.parse.urlparse(f["fields"]["Policy"][0]).netloc.lower() for f in files if f["fields"].get("Policy")) fig["two most common Policy hosts"] = hosts.most_common(2) # ------------------------------------------------------------ public listings h1 = load("hackerone-programs.json") paying = sum(bool(p["offers_bounties"]) for p in h1) fig["HackerOne listings: total, offers_bounties true, false"] = (len(h1), paying, len(h1) - paying) fig["HackerOne share marked as not offering bounties"] = share(len(h1) - paying, len(h1), 0) bc = load("bugcrowd-engagements.json")["programs"] amounts = [] for p in bc: if p["maxReward"] is None: continue if not re.fullmatch(r"\$[\d,]+", p["maxReward"]): raise CheckFailed(f"Bugcrowd reward is not a plain dollar amount: {p['maxReward']!r}") amounts.append(int(p["maxReward"][1:].replace(",", ""))) fig["Bugcrowd listings: total, with a dollar top reward, without"] = (len(bc), len(amounts), len(bc) - len(amounts)) fig["Bugcrowd median, lowest and highest top reward (USD)"] = (statistics.median(amounts), min(amounts), max(amounts)) ig = load("intigriti-programs.json") ig_stated = [p["max_bounty"] for p in ig if p["max_bounty"] and p["max_bounty"]["value"]] ig_eur = [b["value"] for b in ig_stated if b["currency"] == "EUR"] fig["Intigriti listings: total, with a top reward, of those in EUR"] = (len(ig), len(ig_stated), len(ig_eur)) fig["Intigriti currencies among stated top rewards"] = dict(sorted(collections.Counter(b["currency"] for b in ig_stated).items())) fig["Intigriti median top reward among EUR listings"] = statistics.median(ig_eur) yw = load("yeswehack-programs.json")["programs"] fig["YesWeHack listings: total, marked bounty, marked vdp"] = (len(yw), sum(bool(p["bounty"]) for p in yw), sum(bool(p["vdp"]) for p in yw)) def norm(name): return re.sub(r"[^a-z0-9]", "", re.sub(r"\b(bug bounty|vdp|program|programme|public|managed|vulnerability disclosure)\b", "", name.lower())) names = {"hackerone": {norm(p["name"]) for p in h1}, "bugcrowd": {norm(p["name"]) for p in bc}, "intigriti": {norm(p["name"]) for p in ig}, "yeswehack": {norm(p["title"]) for p in yw}} seen = collections.Counter(n for group in names.values() for n in group if n) fig["listings on four platforms combined"] = len(h1) + len(bc) + len(ig) + len(yw) fig["normalized names that appear on more than one platform"] = sum(1 for count in seen.values() if count > 1) dio = load("diodb-program-list.json") bounty = collections.Counter((p.get("offers_bounty") or "blank").lower() for p in dio) harbor = collections.Counter((p.get("safe_harbor") or "blank").lower() for p in dio) stated = bounty["yes"] + bounty["no"] + bounty["partial"] fig["disclose.io entries"] = len(dio) fig["disclose.io offers_bounty yes, no, partial, blank"] = tuple( (bounty[k], share(bounty[k], len(dio))) for k in ("yes", "no", "partial", "blank")) fig["disclose.io entries stating a position, share of those saying yes"] = (stated, share(bounty["yes"], stated, 0)) fig["disclose.io safe_harbor full, partial, none"] = (harbor["full"], harbor["partial"], harbor["none"]) # ------------------------------------------------------------ arithmetic on published figures fig["Google 2025: USD 17.1 million / 747 paid researchers, to the nearest 100"] = round(17_100_000 / 747, -2) # ------------------------------------------------------------ invented cost model fig["model, 15% valid"] = month(VALID_SHARE) fig["model, 8% valid"] = month(0.08) fig["model, 25% valid"] = month(0.25) fig["rise in cost per valid report from 15% to 8% valid"] = share(month(0.08)["per_valid"] - month(0.15)["per_valid"], month(0.15)["per_valid"], 0) for name, value in fig.items(): print(f"{name}: {value}") if LIVE: print("\nLIVE MODE: recalculated from the local files. Nothing was compared with the article.") return normal = json.loads(json.dumps(fig)) if set(normal) != set(EXPECTED): raise CheckFailed(f"figure list changed: {sorted(set(normal) ^ set(EXPECTED))}") for name, wanted in EXPECTED.items(): if normal[name] != wanted: raise CheckFailed(f"{name}: recalculated {normal[name]!r}, article says {wanted!r}") print(f"\nFROZEN MODE: {len(EXPECTED_HASHES)} evidence files match their hashes and all {len(EXPECTED)} figures match the article.") EXPECTED = json.loads(r""" { "validator self-tests passed": 30, "tranco list id": "L5KW4", "survey date (UTC)": "2026-11-19", "domains surveyed": 1000, "any HTTP status recorded, including the survey network's own refusals": [ 731, "73.1%" ], "site itself returned an HTTP status": [ 730, "73.0%" ], "requests where a status arrived and the body then failed": 0, "replies longer than the 100,000-byte read cap": 409, "no HTTP status from any address": [ 269, "26.9%" ], "no-response domains by first failure": { "TLS error": 20, "connection could not be established": 213, "timed out": 36 }, "refused by the survey network": 1, "files with a Contact field: count, share of sample, share of sites that answered": [ 219, "21.9%", "30.0%" ], "found at the well-known path, only at the legacy path": [ 210, 9 ], "served as text/plain, as something else": [ 218, 1 ], "files reached after a redirect": 135, "qualifying files cut off by the read cap": 0, "Expires missing": [ 69, "31.5%" ], "Expires not a valid RFC 3339 date-time": [ 6, "2.7%" ], "Expires in the past": [ 10, "4.6%" ], "Expires valid and in the future": [ 134, "61.2%" ], "of those, on or after the one-year anniversary of the survey": [ 45, "20.5%" ], "Expires listed more than once": 0, "passed the four selected checks": [ 133, "60.7%", "13.3%" ], "field Policy": [ 156, "71%" ], "field Preferred-Languages": [ 123, "56%" ], "field Hiring": [ 109, "50%" ], "field Canonical": [ 93, "42%" ], "field Encryption": [ 79, "36%" ], "field Acknowledgments": [ 59, "27%" ], "field CSAF": [ 5, "2%" ], "OpenPGP cleartext signature": [ 31, "14%" ], "Contact with mailto, Contact with https": [ 136, 125 ], "field values with the word bounty": [ 29, "13%" ], "field values naming one of six platforms": [ 76, "35%" ], "either signal": [ 99, "45%" ], "files naming each platform": { "hackerone": 51, "bugcrowd": 15, "intigriti": 8, "yeswehack": 2, "hackenproof": 0, "synack": 0 }, "two most common Policy hosts": [ [ "hackerone.com", 33 ], [ "g.co", 10 ] ], "HackerOne listings: total, offers_bounties true, false": [ 448, 218, 230 ], "HackerOne share marked as not offering bounties": "51%", "Bugcrowd listings: total, with a dollar top reward, without": [ 297, 292, 5 ], "Bugcrowd median, lowest and highest top reward (USD)": [ 3625.0, 500, 3000000 ], "Intigriti listings: total, with a top reward, of those in EUR": [ 146, 68, 50 ], "Intigriti currencies among stated top rewards": { "EUR": 50, "GBP": 1, "USD": 17 }, "Intigriti median top reward among EUR listings": 2562.5, "YesWeHack listings: total, marked bounty, marked vdp": [ 52, 50, 1 ], "listings on four platforms combined": 943, "normalized names that appear on more than one platform": 1, "disclose.io entries": 2433, "disclose.io offers_bounty yes, no, partial, blank": [ [ 437, "18.0%" ], [ 978, "40.2%" ], [ 1, "0.0%" ], [ 1017, "41.8%" ] ], "disclose.io entries stating a position, share of those saying yes": [ 1416, "31%" ], "disclose.io safe_harbor full, partial, none": [ 589, 591, 492 ], "Google 2025: USD 17.1 million / 747 paid researchers, to the nearest 100": 22900.0, "model, 15% valid": { "valid": 30, "reward_per_valid": 730, "rewards": 21900, "hours": 190, "staff": 14250, "total": 36150, "per_valid": 1205, "staff_share": "39%", "reward_share": "61%" }, "model, 8% valid": { "valid": 16, "reward_per_valid": 730, "rewards": 11680, "hours": 148, "staff": 11100, "total": 22780, "per_valid": 1424, "staff_share": "49%", "reward_share": "51%" }, "model, 25% valid": { "valid": 50, "reward_per_valid": 730, "rewards": 36500, "hours": 250, "staff": 18750, "total": 55250, "per_valid": 1105, "staff_share": "34%", "reward_share": "66%" }, "rise in cost per valid report from 15% to 8% valid": "18%" } """) if __name__ == "__main__": try: main() except CheckFailed as problem: sys.exit(f"CHECK FAILED: {problem}")