fix(api/skills): sanitize error messages before returning them to clients - #9088
Merged
diegosouzapw merged 2 commits intoAug 6, 2026
Conversation
…ents
The /api/skills/** routes returned `{ error: err.message }` verbatim on a
500. Because skillRegistry performs filesystem work, an EACCES/ENOSPC surfaces
an absolute path (e.g. `open '/home/<user>/.omniroute/skills/<name>/handler.js'`)
straight to the caller — the exact stack/path leak Hard Rule diegosouzapw#12 and the repo's
own sanitizeErrorMessage guard against (126 of 175 API routes already sanitize).
Route the caught message through sanitizeErrorMessage in the 10 catch blocks
across the 8 skills routes. The response shape is deliberately left as
`{ error: string }`: the omni-skills dashboard reads `data.error` as a string
(OmniMarketplaceTab.tsx, OmniSkillsPageClient.tsx), so switching to
buildErrorBody's `{ error: { message } }` would break the UI. collect/detect
already uses buildErrorBody and is left untouched.
Adds tests/unit/skills-routes-error-sanitization.test.ts: forces
skillRegistry.loadFromDatabase to throw an error carrying an absolute path and
asserts GET /api/skills returns a 500 whose string body no longer leaks it.
5 tasks done
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…ents (diegosouzapw#9088) Validated in local merge-train T5 (base49+contributors+pacocartones)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
The
src/app/api/skills/**routes returned the raw error message to the client on a 500:skillRegistryreads/writes the skills directory, so a filesystem failure (EACCES/ENOSPC) surfaces an absolute path verbatim to the caller, e.g.EACCES: permission denied, open '/home/<user>/.omniroute/skills/<name>/handler.js'. That's the stack/path leak Hard Rule #12 — and the repo's ownsanitizeErrorMessage— already guard against (126 of 175src/app/api/**/route.tsfiles sanitize; these skills routes were among the ~49 that didn't).Change
Route the caught message through
sanitizeErrorMessagein the 10 catch blocks across 8 skills routes:sanitizeErrorMessageis linear-time (CodeQLjs/polynomial-redos-clean) and strips stack tails + absolute source paths and redacts sensitive tokens, leaving ordinary messages intact — so theexecutionsroute'sif (error.includes("disabled"))503 branch still works.Scope decisions (deliberate)
{ error: string }, not migrated tobuildErrorBody. The omni-skills dashboard readsdata.erroras a string (OmniMarketplaceTab.tsx:53/83/100/129,OmniSkillsPageClient.tsx:153:(data as { error?: string }).error). Returning{ error: { message } }would render[object Object]in the UI. This PR fixes the leak without changing the contract.collect/detect/route.tsleft untouched — it already usesbuildErrorBody.Files:
skills/route.ts,[id]/route.ts(×2),executions/route.ts(×2),install/route.ts,marketplace/route.ts,marketplace/install/route.ts,skillssh/route.ts,skillssh/install/route.ts.Tests
Adds
tests/unit/skills-routes-error-sanitization.test.ts: monkey-patchesskillRegistry.loadFromDatabaseto throw an error carrying an absolute path, callsGET /api/skills, and asserts the 500 body is still astringand no longer contains the path.No response-shape change; no public behavior change beyond redacted error text.