Remote exit nodes get their Traefik config from /hybrid/traefik-config
with local sites included, and dial those targets inside the customer's
own network, where localhost targets are normal. The previous commit
applied the local-site restrictions to them too.
- createSite only checks flags.disable_local_sites, not
traefik.site_types (SaaS has ["newt"] centrally but serves local sites
through remote exit nodes).
- Target validation for local sites runs only when Pangolin's own Traefik
serves the site (no exit node or a non-remote exit node), in
createTarget, updateTarget and blueprints.
- The private Traefik config skips bad local targets only when the config
is not for a remote exit node.
- Migration notes updated, including a query that excludes remote-node
sites.
PAN-1885
Deployments where Traefik never polls the HTTP provider (file_mode edge
nodes, Kubernetes CRDs) can now switch the endpoint off instead of
managing a token.
PAN-1885
bannedEmails only matched exact addresses, so an attacker on a disposable
domain kept signing up with new addresses (and "+tag" variants), and the
list was not checked at all for users provisioned through an OIDC IdP.
- bannedEmailCandidates: exact address, address without "+tag", and
"@domain" for the domain and each parent domain (never a bare TLD).
- isEmailBanned is used by signup and by validateOidcCallback before a
new OIDC user is created.
AI provider upstreamUrl was only z.url() and the AI gateway streamed the
upstream response back, so any org admin could read internal services,
Pangolin's own internal API or the cloud metadata service (prod had a
provider pointed at 169.254.169.254). Alert webhooks and HTTP log
streaming fetched any URL and followed redirects.
- server/lib/outboundAddress.ts (no config dependency, unit tested):
always refuses loopback, unspecified, link-local, broadcast, multicast
and reserved addresses (incl. IPv4-mapped forms), localhost and
Pangolin's own service names; refuses RFC1918/ULA/CGNAT when private
outbound is blocked. Provides a resolver check and a connect-time DNS
lookup so rebinding cannot get around it.
- server/lib/outboundUrlGuard.ts: policy from config. New
flags.block_private_outbound_urls defaults to on for SaaS, off for
self-hosted (local models).
- aiGatewayUpstreamFetch checks the host and passes the guarded lookup to
every upstream request; create/updateAiProvider reject blocked URLs.
- sendAlertWebhook and HttpLogDestination check the URL before sending
and no longer follow redirects.
- Migration notes cover the flag and a query for providers that will
stop working.
PAN-1799 (3v9x, 4g5q)
Traefik dials a local site's targets from inside Pangolin's own network, so
an org admin could create a local site with a target such as pangolin:3001
and publish the internal API (including the unauthenticated
/traefik-config, which lists every org's header values and gateway trust
tokens) on their own hostname. disable_local_sites was only read by the
dashboard; the server-side check in createSite was commented out.
- createSite refuses local sites when flags.disable_local_sites is set or
"local" is not in traefik.site_types, and basic WireGuard sites when
flags.disable_basic_wireguard_sites is set.
- New localSiteTargetError rejects loopback, unspecified, link-local
(incl. 169.254.169.254), broadcast, localhost, the internal hostname,
gerbil, traefik and badger. createTarget, updateTarget and blueprint
targets refuse them on local sites, and both Traefik config generators
skip existing ones.
- Optional traefik.config_token: when set, GET /traefik-config requires
"Authorization: Bearer <token>" (constant-time compare). Unset keeps the
old behaviour and logs a warning once. The installer now generates the
token and writes it to config.yml and Traefik's HTTP provider headers.
- Migration notes for 1.28.0 cover the config change and a query for
existing targets that will stop routing.
PAN-1885 / GHSA-jrw8, rx89 part of PAN-1799
Redirects are answered before auth and outrank resource routers, but
createRedirect/updateRedirect only checked that the org held the domain.
Any org admin could put a redirect on another org's resource host or on
the dashboard host (the config-managed wildcard domain is linked to every
org) and receive its traffic, including p_token and share links.
Blueprints also skipped the dashboard-host and login-page checks that
createResource has.
- server/lib/reservedHosts.ts: checkReservedHost (dashboard host and login
page domains, wildcard-aware, including matchBaseDomain) and
checkRedirectHostAvailable (also rejects another org's resource or
redirect on the same host; same-org resources stay allowed).
- createRedirect/updateRedirect call checkRedirectHostAvailable.
- createResource, updateResource and the blueprint getDomain call
checkReservedHost, replacing the inline exact-match checks.
PAN-1850 / GHSA-8545 (dup GHSA-9j9g, GHSA-crh2), PAN-1813
Access middlewares cache the caller's org link on req.userOrg and
req.apiKeyOrg and skip their membership query when it is already set.
A value inherited from a polluted Object.prototype passed that check.
- Give every request its own undefined copy of the cached auth fields
(userOrg, apiKeyOrg, userOrgRoleIds, userOrgId, userOrgIds,
orgPolicyAllowed) before any route runs, on the API, integration,
internal and AI gateway servers.
- Add ownUserOrg/ownApiKeyOrg, which return a cached value only if it is
an own property for the signed-in user or calling key.
- Every user and API key access middleware now uses them and refuses
when the cached org does not match the org of the object being
accessed. verifyApiKeySiteAccess and verifyApiKeySiteResourceAccess
had no org comparison at all once req.apiKeyOrg was set.
Defence in depth for PAN-1814 / GHSA-5fhj.
The resource blueprint AuthSchema typed pincode as a number between
100000 and 999999, so PINs starting with 0 ("012345", a tenth of all
valid PINs) could not be expressed, although the PIN API accepts any
^\d{6}$ string. Resource-policy blueprints had the opposite problem and
rejected an unquoted pincode: 123456. Docker labels lost leading zeros
too, because convertValue turned every digit string into a number.
Use one PincodeSchema for both: a 6-digit string, or a number in the old
range normalized to a string. convertValue leaves digit strings with a
leading zero as strings. Existing configs keep working.
Signed-off-by: anant <170962632+antcybersec@users.noreply.github.com>
aiBudgetEnforcement.test.ts and deleteOrg.test.ts create a workdir with
mkdtempSync (temp SQLite DB, config and symlinks into the repo) and never
remove it, so every npm test run leaves two pangolin-* directories in the
OS temp dir. Remove the workdir in a finally block, the same way
migrationsSqlite.backup.test.ts already does. rmSync does not follow the
symlinks, so the repo's server/, test/ and node_modules/ are untouched.
Signed-off-by: anant <170962632+antcybersec@users.noreply.github.com>
invoke-with-response-stream wraps each model event as {"bytes":"<base64>"} inside event-stream frames, so the usage fields never appear in clear text. extractUsage returned null and the pipeline fell back to estimating tokens over the base64, losing real counts and cache tokens. Decode the chunks before scanning.
aiUsageRecords.createdAt is epoch seconds since e57826d6e, but
sumUsageForBudget still compared it against a lower bound in epoch ms, so
every budget except lifetime summed to 0.
Convert the bound to seconds for usage queries, leaving windowStart in ms
for aiBudgetBreachEvents. Sum model-scoped budgets per requested model in
SQL instead of loading every row in the window into JS.
extractOpenAiResponses only took response.usage from response.completed, so a
stream cut by max_output_tokens (response.incomplete) lost its usage and fell
back to estimateUsage over the whole SSE text, over-counting cost and budget.
Read response.usage from any event that carries it.
Gemini reports the tokens of tool results (Google Search, URL context) in usageMetadata.toolUsePromptTokenCount, separate from promptTokenCount. The extractor ignored it, so usage and cost were under-counted.
sendToExitNode used axios without a timeout, so a Gerbil that accepted
the connection but never answered left the caller (peer updates, SNI
sync, client association rebuilds) waiting indefinitely. Apply a 15s
default, overridable per request.
With prompt caching enabled, Bedrock reports inputTokens as the non-cached input only; cacheReadInputTokens and cacheWriteInputTokens are separate counters. Subtracting the cache reads again undercounted promptTokens (clamped to 0) in both the JSON and the stream-scan paths.
Reworks the org-scoped exchange-token endpoint into a root-gated create-session route,
addressing the review on the earlier version:
- Requires a ROOT API key holding the createIdpSession action, not an org-scoped key.
Minting a session is impersonation, so it is deliberately root-only.
- Gated behind flags.enable_idp_create_session (off by default, self-hosted only;
refused when build === "saas").
- Drops orgId entirely: the user must belong to the identity provider, not an
organization. The route becomes /idp/:idpId/oidc/create-session.
Removes the now-unused org-scoped createSessionForIdpUser helper.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>