Skip to content

Security: Upiottxat/Free-Provider

Security

docs/security.md

Security

How Free Provider handles authentication, secrets, cookies, and logging — and what operators should be aware of.


API key

  • Generated on first run and stored in .api-key (or read from OPENAI_API_KEY env var).
  • Sent by clients as Authorization: Bearer <key>.
  • Compared via simple string equality in server/middleware/auth.mjs.
  • Not rotated automatically — rotate manually by editing .api-key or changing OPENAI_API_KEY.

Treat the key like any bearer token: keep it out of logs and don't share publicly.


ChatGPT cookies

An optional client/cookies.json can unlock authenticated features:

[
  { "name": "__Secure-next-auth.session-token", "value": "..." },
  { "name": "cf_clearance", "value": "..." }
]
  • Format: array of { name, value } objects (see client/cookies.json.example).
  • Stored in plaintext on disk — treat like a session cookie / credential.
  • Only required for endpoints that need an authenticated ChatGPT session.

Proxies

Proxy URLs may contain credentials (socks5://user:pass@host:1080). They are configured via:

  • The PROXY_URLS environment variable, or
  • A PROXIES.txt-style file (default client/proxies.txt).

Treat the proxy list like a secret: put it in .env (gitignored) or client/proxies.txt (gitignored) — commit only the proxies.txt.example template. Credentials are never written to logs. If you expose the server publicly, rotate proxy credentials if they leak via any other route.


Logging

Every chat request is logged to both stdout and server/chat.log:

{"timestamp":"2026-09-13T08:16:17.749Z","type":"completion","stream":true,"model":"gpt-4o","user":["Say hi"],"assistant":"Hi there!"}

Fields:

Field Type Description
timestamp ISO 8601 When the completion finished
type "completion" Always this value
stream boolean True if SSE streaming was used
model string Model id from the request
user string[] User messages from the request
assistant string Full assistant response
error string/null Error message if the request failed

What is not logged

  • The API key (headers are stripped)
  • ChatGPT cookies
  • Upstream request/response headers (only bodies)

Log file retention

chat.log is a plain append-only file — no rotation is performed by the server. For production deployments, hook up a log rotator or ship to a collector.


Secrets summary

Secret Location Rotation
API key .api-key / OPENAI_API_KEY env Manual
ChatGPT cookies client/cookies.json Export new cookies from browser
Per-request conversation state In-memory only (ChatGPT instance) Auto-reset per request

Threat model & mitigations

Risk Mitigation
Unauthorized API calls Bearer token required on all /v1/* endpoints
Key leakage via logs Keys never written to chat.log or stdout
Cookie theft Store cookies file with restricted permissions; don't commit to VCS
Upstream IP blocking / Cloudflare Server runs locally; operator controls network
Log injection / tampering Log entries are JSON-stringified; consumer should parse safely
CSRF / XSS on web UI No cookies used for UI auth; static file + token-only API
Log PII User & assistant text is written as-is; be mindful of sensitive data in chats

Operator checklist

  • OPENAI_API_KEY is set to a strong, random string
  • .api-key and client/cookies.json are gitignored
  • Log file server/chat.log is monitored / rotated
  • Server runs on a trusted network (no public exposure without TLS + auth)
  • If exposing publicly, terminate TLS at a reverse proxy (nginx/Traefik/Caddy)

There aren't any published security advisories