Access problem on GitHub Organization which using IP Allowlist

Resolved 💬 14 comments Opened May 21, 2025 by powerstrong Closed Nov 25, 2025

Hello, we are testing Codex and trying to connect to our GitHub organization.
Our organization has IP allowlisting enabled on GitHub Enterprise. Despite enabling the option to bypass IPallowlist for OAuth apps, codex is unable to access our repos.
Is there any way to allow Codex access to IP Allowlisted GitHub Organization?
Or can I know your public IP ranges so that I can add IP ranges into our list?

View original on GitHub ↗

14 Comments

shanehughes1990 · 1 year ago

I'm in the same boat, I did come across a page on there docs for action IP CIDR ranges. https://platform.openai.com/docs/actions/production#ip-egress-ranges.

I wrote a little bash script to add them via GitHub's graph API to our organization whitelist all 87 CIDRs I believe it was. We still get the "problem setting up environment" error in codex.

The script @powerstrong if you wanted to try it too just requires your token (needs org:admin) & your org name at the top

#!/bin/bash

set -e

# Configuration - replace these values
GITHUB_TOKEN=""
GITHUB_ORG=""

# Check if required variables are set
if [ -z "$GITHUB_TOKEN" ]; then
	echo "Error: GitHub token not set. Please set GITHUB_TOKEN variable in the script."
	exit 1
fi

if [ -z "$GITHUB_ORG" ]; then
	echo "Error: GitHub organization not set. Please set GITHUB_ORG variable in the script."
	exit 1
fi

echo "Fetching OpenAI IP prefixes..."
OPENAI_JSON=$(curl -s https://openai.com/chatgpt-actions.json)

# Extract IP prefixes
IP_PREFIXES=$(echo "$OPENAI_JSON" | grep -o '"ipv4Prefix": "[^"]*"' | cut -d'"' -f4)

echo "Extracted IP prefixes: $IP_PREFIXES"

if [ -z "$IP_PREFIXES" ]; then
	echo "Error: Failed to extract IP prefixes from OpenAI's JSON."
	exit 1
fi

echo "Found $(echo "$IP_PREFIXES" | wc -l | tr -d ' ') IP prefixes."

# Add each IP to GitHub allowed list
counter=1
for ip in $IP_PREFIXES; do
	echo "Adding IP $ip to GitHub allow list as OpenAI-$counter..."

	# First get organization's node_id
	ORG_NODE_ID=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/orgs/$GITHUB_ORG | jq -r .node_id)

	# Create GraphQL mutation payload - properly escaped JSON
	# GitHub API documentation: https://docs.github.com/en/graphql/reference/mutations#createipallowlistentry
	GQL_QUERY=$(
		cat <<EOF
{
  "query": "mutation { createIpAllowListEntry(input: { ownerId: \"${ORG_NODE_ID}\", allowListValue: \"${ip}\", name: \"OpenAI-${counter}\", isActive: true }) { ipAllowListEntry { id allowListValue name } } }"
}
EOF
	)

	# Make API call to GitHub GraphQL API
	HTTP_RESPONSE=$(curl -s -w "STATUS:%{http_code}" \
		-X POST \
		-H "Content-Type: application/json" \
		-H "Accept: application/json" \
		-H "Authorization: Bearer $GITHUB_TOKEN" \
		"https://api.github.com/graphql" \
		-d "$GQL_QUERY")

	HTTP_BODY=$(echo "$HTTP_RESPONSE" | sed -e 's/STATUS\:.*//g')
	HTTP_STATUS=$(echo "$HTTP_RESPONSE" | sed -e 's/.*STATUS\://g')

	# Check for errors in GraphQL response
	if [[ "$HTTP_STATUS" == "200" ]]; then
		if echo "$HTTP_BODY" | grep -q "errors"; then
			echo "Failed to add IP $ip. Response:"
			echo "$HTTP_BODY"
		else
			# Extract created entry ID from successful response
			ENTRY_ID=$(echo "$HTTP_BODY" | grep -o '"id":"[^"]*"' | head -1 | cut -d'"' -f4)
			echo "Successfully added IP $ip as OpenAI-$counter (ID: $ENTRY_ID)"
		fi
	else
		echo "Failed to add IP $ip. HTTP Status: $HTTP_STATUS"
		echo "$HTTP_BODY"
	fi

	counter=$((counter + 1))

	# Avoid rate limiting
	sleep 1
done

echo "Completed adding OpenAI IP prefixes to GitHub allow list."
phil-hotchkiss · 1 year ago

I agree that this would be a useful feature. We've reached out to enterprise support directly, but if this could be implemented in a way that supports IP restrictions in Github organizations or allows a bypass, that would be great.

powerstrong · 1 year ago

Now my Codex can access to my IP allowlist enabled GitHub Org. However I'm not sure if it's because it happend to match one of my registered CIDRs, or because the ChatGPT Connector or the ChatGPT Verification app started working a day late.

@shanehughes1990 Thanks though. I will try your script if the problem occurs again.

shanehughes1990 · 1 year ago

Lol I'm still struggling over here not, we've resorted to mirrors to our personal accounts for the time being lol. I will have to try the Github openapt connector app. Thanks for the tip

powerstrong · 1 year ago

Sadly Codex can't access to my GitHub right now. So it's pretty seems that in the past Codex had been included my allowlist range luckily, but not this time.

phil-hotchkiss · 1 year ago

This IP allow list is vast and not guaranteed to be operated by OpenAI. If the Codex GitHub Connector app adds 0.0.0.0/0 to the IP Allow list for the app (screenshot below) this would allow the app to authenticate from any IP address, while allowing us to leave existing IP address restrictions in place for other clients

!Image

GitHub Organization accounts that have IP allow lists enabled, as we do, would see something like the following in their IP allow list:

!Image

powerstrong · 1 year ago

@phil-hotchkiss Thanks for your answer. Do you mean I need to create my own app and add '0.0.0.0/8'? If so, how to my app links to Codex?

phil-hotchkiss · 1 year ago

@powerstrong No, my suggestion is for Open AI to implement this feature. It is a native behavior of Github Apps. It seems a reasonable way for them to maintain IP address lists from within their application instead of requiring any organization using IP restrictions to manually maintain address lists that are not guaranteed to be leveraged by OpenAI.

powerstrong · 1 year ago

@phil-hotchkiss After I made a test GitHub app, now I understand what you're saying. Yeah, I think that's the only way if OpenAI doesn't want to open their IP ranges.

htakatsuka · 1 year ago

any updates on this?

rokx · 9 months ago
GITHUB_TOKEN

@shanehughes1990 where do i generate the GITHUB_TOKEN for organization?

shanehughes1990 · 9 months ago

@rokx it's just a PAT you generate under an account having access to modify the whitelist on the organization.

rokx · 9 months ago
@rokx it's just a PAT you generate under an account having access to modify the whitelist on the organization.

I had to create a PAT - Token (classic). New fine-grained tokens did not work. Thank you @shanehughes1990

ghost · 5 months ago

btw: token should have admin:org or admin:enterprise roles