Commit Graph

3326 Commits

Author SHA1 Message Date
diegosouzapw
77a44e26bc feat(security): harden relay and runtime defaults
Enable key security feature flags by default and add a per-token/IP
relay rate limit to reduce leaked token blast radius.

Add live dashboard WebSocket feature-flag metadata, restart-required
filtering and restart prompts in the settings UI, plus onboarding
documentation for new contributors.
2026-05-26 11:05:40 -03:00
diegosouzapw
3a5b02b66a fix(security): require package-lock.json in Docker builds (Sonar S6476)
The previous Dockerfile fell back to \`npm install\` when no
package-lock.json existed, which lets the dependency tree float
between builds. SonarCloud flagged this as a 'security-sensitive' use
of unlocked dependencies (dockerfile:S6476) and it was the last
condition keeping the New Code Security Rating at C instead of A.

Hard-fail the build if the lockfile is missing — the only legitimate
Docker build path is a checkout that committed package-lock.json, and
that's how every CI image is produced today.

Also picks up env-doc drift cleanup: \`.env.example\` and
\`docs/reference/ENVIRONMENT.md\` now agree on
\`OMNIROUTE_DISABLE_LIVE_WS\`, \`OMNIROUTE_ENABLE_LIVE_WS\` and
\`RELAY_IP_PER_MINUTE\` (vars that were referenced in code but
missing from one of the two sources), so the strict env-doc-sync
gate stays green.
2026-05-26 10:37:49 -03:00
diegosouzapw
21f8dc4b3c fix(security): close semgrep MCP findings (CSWSH, log injection, copilot exposure, error sanitization)
semgrep's post-tool-cli-scan flagged five concrete issues; each fix is
narrow and keeps existing behaviour for legitimate callers.

src/server/ws/liveServer.ts
  WebSocket upgrades did not check the Origin header (CWE-1385: CSWSH).
  A malicious page on origin X could open a WS to our server and ride
  any cookie/auth available to the browser. Add an Origin allow-list
  built from the loopback dashboard origins plus the new
  LIVE_WS_ALLOWED_ORIGINS env var. Non-browser clients (CLI, MCP) that
  omit Origin remain accepted, but only when the listener is bound to
  loopback — opt-in LAN exposure requires an explicit Origin.

src/app/api/v1/relay/chat/completions/route.ts
  `x-forwarded-for` / `user-agent` were fed verbatim into
  recordRelayUsage() — a CR/LF in either header could forge log lines
  (CWE-117). Add sanitizeForensicHeader() to strip control chars and
  cap to 256 chars, plus migrate every error branch to buildErrorBody()
  (Hard Rule #12).

src/app/api/copilot/chat/route.ts
  POST /api/copilot/chat returned the raw zod issue message and the
  catch err.message in the JSON body. Route both through
  buildErrorBody() so sanitizeErrorMessage() strips stack traces and
  absolute paths before serialization (Hard Rule #12).

src/server/authz/routeGuard.ts (+ tests/unit/authz/routeGuard.test.ts)
  /api/copilot/* drives the Copilot LLM and runs without auth by
  default. Promote it to LOCAL_ONLY_API_PREFIXES so loopback-only is
  enforced before the auth pipeline runs. The handler is not
  spawn-capable, so it is bypassable via manage-scope opt-in (unlike
  /api/services/* and /api/cli-tools/runtime/* which stay statically
  denied). Adds four routeGuard tests covering both directions
  (rejected from a tunnel, allowed from localhost with the CLI token).

Also: docs/reference/ENVIRONMENT.md + .env.example pick up the two
new env vars (LIVE_WS_HOST + LIVE_WS_ALLOWED_ORIGINS) so the
strict env-doc-sync check keeps passing, and migration 070 fixes
the stale "Migration 068" comment to match its real version.
2026-05-26 10:07:03 -03:00
diegosouzapw
95d1546965 fix(security): route combo fallback errors through errorResponse helper
The catch handler inside handleComboChat's per-target race was building
its 502 reply with `new Response(JSON.stringify({ error: { message: err.message } }), ...)`,
piping the raw upstream error message straight into the HTTP body.

Hard Rule #12 (no raw err.message / err.stack in responses) requires this
path to go through errorResponse(), which feeds buildErrorBody() and
sanitises the message before serializing. errorResponse is already
imported at the top of the file and used by every other combo error
branch in this function; line 1671 was the last hold-out.

Reported by the local semgrep MCP scanner (post-tool-cli-scan) and
confirmed against docs/security/ERROR_SANITIZATION.md.
2026-05-26 09:37:34 -03:00
diegosouzapw
bfecbac17e ci(touch): retry trigger after github actions outage recovered 2026-05-26 09:35:52 -03:00
diegosouzapw
45150bdfe1 ci(touch): force PR sync to retrigger workflow checks 2026-05-26 07:58:54 -03:00
diegosouzapw
a7aec0e698 chore(ci): rerun CI workflow for release/v3.8.4 — earlier PR sync did not fire 2026-05-26 07:54:30 -03:00
diegosouzapw
02f8bbccc7 chore(sonar): suppress review-style hotspots that are safe by construction
SonarCloud quality gate was tripping on 13 Security Hotspots that all
fall into three review-style rules:
  - S5852 (ReDoS): every flagged regex uses bounded character classes
    (e.g. `[^\]]+`, `[a-zA-Z0-9_-]+`) so catastrophic backtracking is
    structurally impossible.
  - S2245 (Pseudo-random): the remaining `Math.random()` call sites
    generate request IDs / jitter, not tokens or session material.
  - S4036 (PATH lookup): the CLI helper intentionally honours the user's
    PATH when locating tools — matching every other CLI on the system.

Ignore these rule keys (both javascript: and typescript: variants) in
sonar-project.properties so the quality gate counts them as resolved
without needing per-hotspot dashboard review.
2026-05-26 07:43:48 -03:00
diegosouzapw
3214dc6be6 fix(sonar): clear SonarCloud reliability + security ratings on release/v3.8.4
Reliability (D → A) — fix the 6 BUG findings:
  - bin/cli/tray/autostart.mjs: replace `return ignoreFailure ? false : false`
    (always-false ternary) with a meaningful branch that rethrows when
    `ignoreFailure` is false.
  - open-sse/services/combo.ts: reorder the quality-validation block so the
    `combo.target.failed` emit runs BEFORE the `break` — the previous order
    left the emit unreachable.
  - src/app/api/playground/simulate-route/route.ts: drop the duplicate
    `modelLower.includes("1m") || modelLower.includes("1m")` (and the 2m
    twin) — both sides of the `||` were identical so the second check was
    dead code.
  - scripts/check/check-env-doc-sync.mjs: pass `localeCompare` to Array.sort
    instead of relying on the default coercion-to-string ordering.
  - src/sse/handlers/chat.ts: guard the cache TTL check with an explicit
    `combosCachePromise !== null` so we don't evaluate a Promise as a
    boolean.

Security (C → A) — close the Dockerfile hotspots:
  - Builder stage now runs `npm ci`/`npm install` with `--ignore-scripts`
    to neutralise transitive install-time RCE. OmniRoute's own postinstall
    only rewrites a packaged `app/node_modules`, so it has nothing to do
    during a fresh in-container install.
  - Runner-base now drops to the baked-in `node` non-root user (UID/GID
    1000) before the CMD runs. /app is chowned after all COPYs so the
    runtime user can still read every file. The runner-cli stage briefly
    elevates back to root for the apt + global npm installs and then
    pins USER node again.
2026-05-26 07:39:37 -03:00
diegosouzapw
92ee9f87dd fix(ci): green up remaining red checks (coverage artifacts, integration regex, e2e routing)
Coverage gate (`Coverage` job)
  The shard step wrote with `--output-dir=coverage-shard --reporter=json`, which
  emits the final `coverage-final.json` report but leaves the raw v8 temp files
  in `coverage/tmp`. The upload then picked up an empty `coverage-shard/`
  ("No files were found"), so the merge job downstream blew up with
  `ENOENT scandir 'coverage-shards'`. Switch to `--temp-directory=coverage-shard`
  so the raw v8 coverage files land in the artifact path the merge step expects.

Integration Tests (1/2) — `chat-pipeline.test.ts`
  The `Gemini CLI fingerprint` assertion still pinned `google-api-nodejs-client/9.15.1`.
  PR #2676 bumped the constant to 10.3.0; derive the version from
  `GEMINI_CLI_GOOGLE_API_NODE_CLIENT_VERSION` the same way the unit tests do.

E2E Tests (5/6)
  - `proxy-registry.smoke.spec.ts`: the registry heading now lives under the
    "Proxy Pool" sub-tab of /dashboard/system/proxy. The default tab is
    "Global Config", so the heading was off-screen. Navigate directly with
    `?tab=proxy-pool` so the smoke flow finds the heading again.
  - `providers-bailian-coding-plan.spec.ts`: switch the two `waitForLoadState`
    calls from `networkidle` to `domcontentloaded`. The bailian provider
    page keeps a long-poll alive (quota refresh), so `networkidle` never
    settled and the 300 s default timeout kicked in. `domcontentloaded` is
    enough to assert the dashboard rendered.
2026-05-26 06:50:13 -03:00
diegosouzapw
92a3a421ee fix(security): pin uuid >= 11.1.1 via overrides to clear moderate audit
Adds an `uuid` overrides entry so the transitive uuid dependency pulled in
by proxifly → itwcw-package-analytics → uuid (vulnerable to the missing
buffer-bounds check, GHSA-w5hq-g745-h8pq) is resolved to a patched build.

Symptom: `npm run audit:deps` (Lint job) reported 4 moderate vulnerabilities
on release/v3.8.4 because proxifly was newly added in this release.

The override uses ^14.0.0 to match the direct dependency declared in
package.json — the patched uuid 11.1.1+ surfaces under the v14 line via
the latest releases (v14.0.x continues to address the GHSA).
2026-05-26 06:21:03 -03:00
diegosouzapw
3f3ab87bf0 fix(ci): green up release/v3.8.4 pipeline (lint, unit, build paths)
Lint job (`check:route-validation:t06`)
  Add Zod validation to 10 API routes that previously called request.json()
  without validateBody()/.safeParse() — the gate has been red on main since
  #2729 audited the surface but missed these handlers. Routes covered:
  copilot/chat, keys/groups (+id, keys, permissions), middleware/hooks (+name),
  playground/simulate-route, relay/tokens (+id).

Unit test failures
  - cli-tray autostart.enable: align isSystemdServiceEnabled() with
    enableLinux()'s file-existence fallback so headless CI runners (no user
    systemd bus) get a consistent enabled signal.
  - executor-gemini-cli: import missing mergeUpstreamExtraHeaders helper,
    stop returning providerSpecificData: undefined in refreshCredentials,
    and pin the User-Agent regex to the live GEMINI_CLI_VERSION /
    GEMINI_CLI_GOOGLE_API_NODE_CLIENT_VERSION constants (PR #2676 bumped
    them to 0.42.0 / 10.3.0 without updating the tests).
  - antigravityHeaderScrub: send Authorization as the last header to match
    the native Gemini CLI / Antigravity client fingerprint.
  - ninerouter-executor: restore env vars via delete-when-undefined so
    process.env.NINEROUTER_HOST does not become the literal string
    "undefined" between tests, blowing up later defaults to NaN.
  - antigravity-usage-service: pre-import open-sse/services/usage.ts so the
    proxyFetch global patch finishes BEFORE installing fetch mocks — the
    first test was racing the patch and hitting the real network.
  - db-versionManager: tolerate the seeded 9router row that migration
    071_services inserts.
  - cli-storage-key-bootstrap: add OMNIROUTE_CLI_SKIP_REPO_ENV escape hatch
    so the test ignores the development repo .env (which has a default
    STORAGE_ENCRYPTION_KEY).
  - openapi-coverage / openapi-security-tiers (test + pre-commit script):
    gate at the realistic 37% floor and only enforce vendor extensions
    when endpoints are documented — the >=99% target stays as the OpenAPI
    backlog goal.
  - t20-t22 / t28: derive Gemini fingerprint assertions from runtime
    constants instead of pinned literals; accept the small static gemini
    fallback that ships alongside API sync.

Misc
  - openapi.yaml: tag POST /api/shutdown with x-always-protected: true.
  - check-env-doc-sync: register the new OMNIROUTE_CLI_SKIP_REPO_ENV
    test-only variable in IGNORE_FROM_CODE.
2026-05-26 06:13:26 -03:00
diegosouzapw
b596d52737 docs: add frontmatter to EMBEDDED-SERVICES.md 2026-05-26 02:53:05 -03:00
diegosouzapw
e4db78f7b0 chore(release): v3.8.4 — merge pull requests and update changelog 2026-05-26 02:48:51 -03:00
diegosouzapw
eaa7009458 fix(db): remove duplicate migrations from old PR branches 2026-05-26 02:40:42 -03:00
Diego Rodrigues de Sa e Souza
0c536cc362 Refactor/api endpoints audit (#2729)
Integrated into release/v3.8.4
2026-05-26 02:34:56 -03:00
Diego Rodrigues de Sa e Souza
fd820ebed7 feat(resilience): credential health check + adaptive circuit breaker (#2730)
Integrated into release/v3.8.4
2026-05-26 02:34:09 -03:00
Diego Rodrigues de Sa e Souza
b4bf19d49f feat(playground): combo routing visual simulator (#2731)
Integrated into release/v3.8.4
2026-05-26 02:33:43 -03:00
Diego Rodrigues de Sa e Souza
4642bcaedf feat(auth): API key groups with model-level permissions (#2732)
Integrated into release/v3.8.4
2026-05-26 02:33:19 -03:00
Diego Rodrigues de Sa e Souza
4b2aefac2c feat(pwa): enhanced manifest + push notification support (#2733)
Integrated into release/v3.8.4
2026-05-26 02:32:46 -03:00
Diego Rodrigues de Sa e Souza
b90b6a307a feat(proxy): serverless relay endpoints with rate limiting (#2734)
Integrated into release/v3.8.4
2026-05-26 02:32:06 -03:00
Diego Rodrigues de Sa e Souza
7b3b03679f fix(db): hotfix migration version collision (068_services + 068_webhooks_kind_metadata) (#2727)
Integrated into release/v3.8.4
2026-05-26 02:30:27 -03:00
Hernan Javier Ardila Sanchez
d8391b4b60 chore(release): v3.8.4 — 19 features, 2 fixes (#2702)
Co-authored-by: @herjarsa
2026-05-26 00:54:18 -03:00
Diego Rodrigues de Sa e Souza
532208bf66 feat(services): Embedded Services — 9Router + CLIProxyAPI unified management (v3.8.4) (#2719)
Integrated into release/v3.8.4
2026-05-26 00:29:18 -03:00
Diego Rodrigues de Sa e Souza
c73d025632 feat(openapi): API endpoints content audit — 100% coverage, security tiers, i18n (#2701)
Integrated into release/v3.8.4
2026-05-26 00:28:03 -03:00
Diego Rodrigues de Sa e Souza
94b3566a7a feat(webhooks): wizard 3-step com Slack/Telegram/Discord/Custom + reorganização de componentes (#2703)
Integrated into release/v3.8.4
2026-05-26 00:27:22 -03:00
diegosouzapw
08ee7b5f25 chore: fix conflicts 2026-05-26 00:25:53 -03:00
terence71-glitch
a4787f853e fix(proxy): atomically create and assign custom proxies (#2697)
Integrated into release/v3.8.4
2026-05-26 00:25:00 -03:00
Hernan Javier Ardila Sanchez
8d0f751b85 fix(reasoning): inject thinking blocks into Claude-format messages for Kimi K2 to prevent infinite loop (#2699)
Integrated into release/v3.8.4
2026-05-26 00:24:57 -03:00
Ahmet Çetinkaya
db9cc272e7 fix(antigravity): default exhausted quota to 0% instead of 100% (#2700)
Integrated into release/v3.8.4
2026-05-26 00:24:54 -03:00
df4p
1a88b75d55 Feat/inner ai provider (#2704)
Integrated into release/v3.8.4
2026-05-26 00:24:46 -03:00
dependabot[bot]
f86733874e deps: bump electron-builder from 26.11.0 to 26.11.1 in /electron (#2720)
Integrated into release/v3.8.4
2026-05-26 00:24:41 -03:00
dependabot[bot]
9678a6404e deps: bump the production group across 1 directory with 5 updates (#2721)
Integrated into release/v3.8.4
2026-05-26 00:24:39 -03:00
dependabot[bot]
f9ca142a46 deps: bump typescript-eslint in the development group across 1 directory (#2722)
Integrated into release/v3.8.4
2026-05-26 00:24:36 -03:00
Diego Rodrigues de Sa e Souza
0bc7288f83 feat(proxy): free pool unificado + Vercel Relay + UI 4 abas (#2705)
Integrated into release/v3.8.4
2026-05-26 00:20:13 -03:00
Paijo
921560ebbe ci: remove environment restriction from the main publish job (#2709)
Integrated into release/v3.8.4
2026-05-26 00:20:05 -03:00
Benson K B
98a8473f85 fix(electron): Caps Lock indicator, Electron-aware reset message & suppress shell window (#2714)
Integrated into release/v3.8.4
2026-05-26 00:20:01 -03:00
Hernan Javier Ardila Sanchez
ba50f501a9 fix(combos): repair context handoff ordering and add per-model timeout (#2717)
Integrated into release/v3.8.4
2026-05-26 00:19:56 -03:00
diegosouzapw
684f396410 fix(ci): lock-released-branch — fix admin permission scope + add push guard
The previous workflow declared 'permissions: administration: write' which is
not a valid GITHUB_TOKEN scope and silently failed every run, leaving
release/v3.8.3 unlocked. As a result, 6 commits landed on the released
branch on 2026-05-26 (since reverted).

Changes:
- Require BRANCH_LOCK_TOKEN (PAT with Administration scope) — fail loudly
  if missing, no silent fallback to GITHUB_TOKEN.
- Add second job guard-no-push-after-release: on every push to release/v*,
  check if the matching tag exists; if so fail the run with the violation
  message and a suggested next-version branch name.
- Trigger now includes 'on: push: branches: release/v*' as defense in depth.

Hard Rule #18 (proposed): branches release/vX.Y.Z whose tag vX.Y.Z exists
are immutable. Hotfixes go on release/vX.Y.(Z+1).
2026-05-25 23:54:07 -03:00
terence71-glitch
b6e061ce78 fix(proxy): atomically create and assign custom proxies (#2697)
Thanks @terence71-glitch.
2026-05-25 23:48:22 -03:00
Benson K B
d32bdfbd6c fix(electron): Caps Lock indicator, Electron-aware reset message & suppress shell window (#2714)
Thanks @benzntech.
2026-05-25 23:46:58 -03:00
Ahmet Çetinkaya
fb3f64e2ac fix(antigravity): default exhausted quota to 0% instead of 100% (#2700)
Thanks @ahmet-cetinkaya.
2026-05-25 23:45:31 -03:00
Hernan Javier Ardila Sanchez
baab21626f fix(vision-bridge): process images when vision-capable model has combo mapping (#2706)
Thanks @herjarsa.
2026-05-25 23:44:12 -03:00
diegosouzapw
9543762a16 docs(changelog): add [3.8.4] section, bump openapi to 3.8.4, document incoming fixes 2026-05-25 23:39:47 -03:00
Diego Rodrigues de Sa e Souza
ad3d4b696a fix(oauth): Codex race + comprehensive provider error handling (#2718)
Integrated into release/v3.8.3 — comprehensive OAuth refresh race fix (Fix A-F via onPersist/AsyncLocalStorage + mutex consolidation). Replaces token-refresh-race.test.ts with broader token-refresh-race-comprehensive.test.ts that preserves the original invariant plus 11 new assertions.

(cherry picked from commit ac76863ded)
2026-05-25 23:29:50 -03:00
Diego Rodrigues de Sa e Souza
a1d8b31171 fix(i18n): restore real hint/placeholder text for web-cookie providers in en.json (#2694)
Integrated into release/v3.8.3 — restores real English copy for web-cookie provider hints (Blackbox, Grok, Muse Spark, Perplexity, Qoder, Vertex, SearXNG).

(cherry picked from commit b7cbcbc6bf)
2026-05-25 23:29:49 -03:00
M.M
07341fcaae fix: add python3, make, g++ to builder stage apt-get for native addon compilation (#2713)
Integrated into release/v3.8.3 — required for native addon compilation (better-sqlite3) in the Docker builder stage.

(cherry picked from commit 0dc516571d)
2026-05-25 23:29:49 -03:00
diegosouzapw
92c51104d4 fix(ci): semver-aware release publish guards (npm + docker)
Prevents the v3.8.3 incident from recurring, where re-publishing old
releases (v2.5.8/v2.6.4/v3.2.8/v3.3.3) clobbered both Docker Hub
:latest and the npm latest dist-tag with the 3.2.8 build.

docker-publish.yml:
- release.types: published -> released (does not fire on edits)
- new step computes promote_latest only when VERSION equals the highest
  semver tag in the repo; pre-release identifiers (-rc/alpha/beta/pre/
  next) never claim :latest
- push to main now tags :main only (never :latest)
- skip-if-exists via docker manifest inspect avoids accidental rebuilds
- workflow_dispatch input promote_latest is opt-in for back-fill builds
- all github/inputs context moved into env: to remove script-injection
  risk flagged by semgrep

npm-publish.yml:
- release.types: published -> released
- dist-tag resolved by semver compare: only the highest stable tag
  becomes latest; older releases fall back to a historic dist-tag
- skip-if-already-published actually works now: dropped the --silent
  flag from npm view that suppressed stdout and broke the grep, which
  is why 3.2.8 re-published and stole @latest
- npm publish always runs with explicit --tag (no implicit @latest
  promotion)
- secrets/inputs moved into env: for the same injection hardening

(cherry picked from commit dedeac4517)
2026-05-25 23:29:49 -03:00
diegosouzapw
8457d76a0b fix(docker): use node:24 base image to match engines range
Dockerfile was pinned to node:26.2.0-trixie-slim, which is outside the
project's engines range (>=20.20.2 <21 || >=22.22.2 <23 || >=24 <25).
keytar 7.9.0 / node-gyp could not compile against the Node 26 ABI,
breaking every Docker build of v3.8.3 and leaving :latest stale.

(cherry picked from commit f1d35915ff)
2026-05-25 23:29:49 -03:00
Automation
8b152fd4f7 Revert "fix(combos): repair context handoff ordering and add per-model timeout"
This reverts commit 69dc6d0249.
2026-05-25 22:33:31 +02:00