Skip to content

Fix Discord false positives: require taken:true marker and tighten regexCheck (#3165) - #3513

Open
DevCop95 wants to merge 1 commit into
soxoj:mainfrom
DevCop95:fix/discord-false-positive
Open

DevCop95 wants to merge 1 commit into
soxoj:mainfrom
DevCop95:fix/discord-false-positive

Conversation

@DevCop95

Copy link
Copy Markdown
Contributor

Summary

Tighten the Discord check (#3165) so invalid-format or unexpected responses from Discord's username-attempt API cannot report false-positive CLAIMED results:

  • Add "presenseStrs": ["{\"taken\":true}"] alongside "absenceStrs": ["{\"taken\":false}"] so only an explicit {"taken":true} confirmation is reported as CLAIMED.
  • Tighten "regexCheck" to ^(?!.*\.\.)[A-Za-z0-9_.]{2,32}$ to match Discord's actual username rules (ASCII letters, digits, underscores, and non-consecutive periods; 2–32 chars).
  • Add USERNAME_INVALID_CHARACTERS and USERNAME_INVALID_REPEATING_DOTS to "errors" as defense in depth.
  • Regenerate maigret/resources/db_meta.json and sites.md (preserving LF line endings).

Fixes #3165

Root Cause

Discord uses POST https://discord.com/api/v9/unique-username/username-attempt-unauthed with checkType: "message", previously had no presenseStrs (is_presense_detected = True by default), and used a broad regexCheck that allowed hyphens (-) and repeating dots (..).

Probing the live API with usernames containing - or .. (such as john-doe, C.fED-X5QAh6_blx8, or NyQ.kppTm_f..gk0zwa0yy) returns HTTP 400:

  • {"message": "Invalid Form Body", "code": 50035, "errors": {"username": {"_errors": [{"code": "USERNAME_INVALID_CHARACTERS", "message": "Username can only use letters, numbers, underscores and periods."}]}}}
  • {"message": "Invalid Form Body", "code": 50035, "errors": {"username": {"_errors": [{"code": "USERNAME_INVALID_REPEATING_DOTS", "message": "Username cannot contain repeating dots."}]}}}

Because HTTP 400 is not flagged by detect_error_page, presenseStrs was empty, and {"taken":false} was absent from the error payload, Maigret reported [+] Discord: https://discord.com (CLAIMED) for any username with - or ...

Live boundary checks against Discord's API confirmed it accepts uppercase letters (Blue -> {"taken":true}), leading/trailing periods (.abc12345, abc12345. -> {"taken":true}), and 2-char names (ab -> {"taken":true}), while rejecting - and .. with HTTP 400 (50035).

Verification

  • Baseline reproduction before edit:
    • python -m maigret john-doe NyQ.kppTm_f..gk0zwa0yy --site Discord --db maigret/resources/data.json --no-autoupdate --dns-resolver threaded -> falsely reported [+] Discord: https://discord.com (1 account each).
  • Post-edit live checks (CONTRIBUTING.md two-filter validation):
    • Filter 1: python -m maigret --self-check --site Discord --db maigret/resources/data.json --no-autoupdate --dns-resolver threaded -> passed cleanly (1/1 in 0.7s).
    • Filter 2: random usernames 1e5fe11b34d6 ([-] Discord: Not found!) and 923a88d920fd ([?] Discord: Site-specific error: Rate limited) -> 0 accounts claimed.
    • Regression: john-doe, NyQ.kppTm_f..gk0zwa0yy, and C.fED-X5QAh6_blx8 -> rejected upfront by regexCheck (Illegal Username Format For This Site!), 0 accounts claimed and no wasted API requests.
  • Synthetic process_site_result checks (6/6 passed):
    • {"taken":true} -> CLAIMED; {"taken":false} -> AVAILABLE; USERNAME_INVALID_CHARACTERS / USERNAME_INVALID_REPEATING_DOTS -> UNKNOWN; unexpected HTTP 200 / HTTP 400 bodies -> AVAILABLE.
  • Unit tests: pytest tests/test_data.py tests/test_sites.py tests/test_country_tags.py tests/test_site_false_positives.py tests/test_errors.py tests/test_error_detection.py tests/test_username_markers.py -> 137 passed.
  • Metadata integrity: Verified LF-only line endings and exact data_sha256 match (b7214cae4dc7f860db50211687796f0ce18eb849039b9c97bdda989716df2e72).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Maigret bot] False-positive site probe: Discord

1 participant