Skip to content

fix(conf): use published IP list for ChatGPT-User verification#19

Open
adri wants to merge 1 commit intocnlangzi:mainfrom
adri:fix/chatgpt-user-ip-verification
Open

fix(conf): use published IP list for ChatGPT-User verification#19
adri wants to merge 1 commit intocnlangzi:mainfrom
adri:fix/chatgpt-user-ip-verification

Conversation

@adri
Copy link
Copy Markdown
Contributor

@adri adri commented Mar 20, 2026

Switch from RDNS-based verification to OpenAI's published IP range list. RDNS is unreliable for OpenAI bots — the official docs recommend using the JSON IP list at openai.com/chatgpt-user.json.

Ref: https://developers.openai.com/api/docs/bots

Summary by Sourcery

Switch ChatGPT-User bot verification to use OpenAI’s published IP range list instead of reverse DNS checks.

Bug Fixes:

  • Replace unreliable RDNS and domain-based verification for ChatGPT-User with URL-based verification using OpenAI’s official chatgpt-user.json IP list.

Enhancements:

  • Configure the ChatGPT-User bot to use the google parser for processing the published IP list.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Mar 20, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR updates the ChatGPT-User bot configuration to follow OpenAI’s official recommendation: instead of verifying via rDNS and domains, it uses the published ChatGPT-User IP range list JSON and sets the appropriate parser.

Sequence diagram for ChatGPT-User verification using published IP list

sequenceDiagram
    actor User
    participant EdgeProxy
    participant BotFirewall
    participant AIAssist_chatgpt_user as AIAssist_chatgpt_user
    participant IPListCache
    participant OpenAI_IP_JSON as OpenAI_chatgpt_user_json

    User->>EdgeProxy: HTTP request with ua ChatGPT-User
    EdgeProxy->>BotFirewall: Forward request and headers
    BotFirewall->>AIAssist_chatgpt_user: Evaluate bot config
    AIAssist_chatgpt_user->>IPListCache: Get IP ranges for ChatGPT_User
    alt cache_hit
        IPListCache-->>AIAssist_chatgpt_user: Return cached IP ranges
    else cache_miss
        IPListCache->>OpenAI_IP_JSON: GET https://openai.com/chatgpt-user.json
        OpenAI_IP_JSON-->>IPListCache: JSON with IP ranges
        IPListCache-->>AIAssist_chatgpt_user: Parsed IP ranges
    end
    AIAssist_chatgpt_user->>AIAssist_chatgpt_user: Check client IP in IP ranges
    alt ip_matches
        AIAssist_chatgpt_user-->>BotFirewall: Mark as verified ChatGPT_User
        BotFirewall-->>EdgeProxy: Allow with bot metadata
        EdgeProxy-->>User: Response
    else ip_not_in_ranges
        AIAssist_chatgpt_user-->>BotFirewall: Not verified
        BotFirewall-->>EdgeProxy: Apply nonbot rules
        EdgeProxy-->>User: Response
    end
Loading

File-Level Changes

Change Details Files
Update ChatGPT-User bot verification from rDNS/domain-based to OpenAI’s published IP list JSON and adjust metadata accordingly.
  • Change reference documentation URL comment from Cloudflare verified-bots docs to OpenAI bots docs URL.
  • Add parser field set to google to the AIAssist configuration.
  • Remove rDNS-based verification and the domains list used for matching OpenAI traffic.
  • Add urls configuration pointing to https://openai.com/chatgpt-user.json to pull the official ChatGPT-User IP ranges.
bots/conf.d/chatgpt-user.yaml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Consider documenting in the config (or a code comment nearby) why the google parser is appropriate for chatgpt-user.json, since the choice isn’t obvious from the name and might confuse future maintainers.
  • If your config/bot framework supports it, consider specifying or verifying reasonable refresh/timeout behavior for the https://openai.com/chatgpt-user.json URL so failures or format changes don’t inadvertently block or misclassify traffic.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider documenting in the config (or a code comment nearby) why the `google` parser is appropriate for `chatgpt-user.json`, since the choice isn’t obvious from the name and might confuse future maintainers.
- If your config/bot framework supports it, consider specifying or verifying reasonable refresh/timeout behavior for the `https://openai.com/chatgpt-user.json` URL so failures or format changes don’t inadvertently block or misclassify traffic.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.80%. Comparing base (60ce193) to head (3444c1b).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main      #19       +/-   ##
===========================================
- Coverage   72.76%   61.80%   -10.97%     
===========================================
  Files          15       24        +9     
  Lines         661     1000      +339     
===========================================
+ Hits          481      618      +137     
- Misses        136      324      +188     
- Partials       44       58       +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Switch from RDNS-based verification to OpenAI's published IP range
list. RDNS is unreliable for OpenAI bots — the official docs recommend
using the JSON IP list at openai.com/chatgpt-user.json.

The "google" parser is used because OpenAI's JSON uses the same format
as Google's IP range lists ({"prefixes": [{"ipv4Prefix": ...}]}).

Ref: https://developers.openai.com/api/docs/bots
@adri adri force-pushed the fix/chatgpt-user-ip-verification branch from a723a28 to 3444c1b Compare March 20, 2026 08:52
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.

1 participant