π‘οΈ Sentinel: Fix sensitive data leakage in error responses#20
π‘οΈ Sentinel: Fix sensitive data leakage in error responses#20AGI-Corporation wants to merge 3 commits intomainfrom
Conversation
Remove JWT tokens and License Keys from `ActivepiecesError` parameters to prevent them from being serialized and sent to the client via the global error handler. Modified Files: - `packages/shared/src/lib/common/activepieces-error.ts`: Update error parameter types. - `packages/server/api/src/app/ee/connection-keys/connection-key.service.ts`: Update error usage. - `packages/server/api/src/app/ee/license-keys/license-keys-controller.ts`: Update error usage. Co-authored-by: AGI-Corporation <186229839+AGI-Corporation@users.noreply.github.com>
π WalkthroughWalkthroughThis PR removes sensitive JWT tokens and license keys from error payloads by changing error param types to empty records and updating places that populated errors to emit empty Changes
Estimated code review effortπ― 3 (Moderate) | β±οΈ ~20 minutes Poem
π₯ Pre-merge checks | β 3β Passed checks (3 passed)
βοΈ Tip: You can configure your own custom pre-merge checks in the settings. β¨ Finishing Touchesπ Generate docstrings
π§ͺ Generate unit tests (beta)
π Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Remove JWT tokens and License Keys from `ActivepiecesError` parameters to prevent them from being serialized and sent to the client via the global error handler. Modified Files: - `packages/shared/src/lib/common/activepieces-error.ts`: Update error parameter types. - `packages/server/api/src/app/ee/connection-keys/connection-key.service.ts`: Update error usage. - `packages/server/api/src/app/ee/license-keys/license-keys-controller.ts`: Update error usage. Co-authored-by: AGI-Corporation <186229839+AGI-Corporation@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
π€ Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.jules/sentinel.md:
- Line 1: Update the incident note header that currently reads "## 2025-03-19 -
Sensitive Data Leakage in Error Parameters" to the correct PR date (replace
2025-03-19 with 2026-03-19) so the sentinel entry's timestamp matches the change
set; ensure the header text "Sensitive Data Leakage in Error Parameters" remains
unchanged.
βΉοΈ Review info
βοΈ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 593c2d8e-4450-4f67-8624-ebf0f357e817
π Files selected for processing (4)
.jules/sentinel.mdpackages/server/api/src/app/ee/connection-keys/connection-key.service.tspackages/server/api/src/app/ee/license-keys/license-keys-controller.tspackages/shared/src/lib/common/activepieces-error.ts
| @@ -0,0 +1,4 @@ | |||
| ## 2025-03-19 - Sensitive Data Leakage in Error Parameters | |||
There was a problem hiding this comment.
Fix the incident note date to match this PR timeline.
Line 1 says 2025-03-19, but this change set is from March 19, 2026. Keeping the exact date accurate matters for security audit trails.
π Suggested patch
-## 2025-03-19 - Sensitive Data Leakage in Error Parameters
+## 2026-03-19 - Sensitive Data Leakage in Error Parametersπ Committable suggestion
βΌοΈ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ## 2025-03-19 - Sensitive Data Leakage in Error Parameters | |
| ## 2026-03-19 - Sensitive Data Leakage in Error Parameters |
π€ Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.jules/sentinel.md at line 1, Update the incident note header that currently
reads "## 2025-03-19 - Sensitive Data Leakage in Error Parameters" to the
correct PR date (replace 2025-03-19 with 2026-03-19) so the sentinel entry's
timestamp matches the change set; ensure the header text "Sensitive Data Leakage
in Error Parameters" remains unchanged.
- Remove JWT tokens and License Keys from `ActivepiecesError` parameters to prevent serialization in API responses. - Restrict `postMessage` target origin in `/redirect` endpoint from `*` to the platform-specific origin for secure OAuth code transmission. - Fix import order in `app.ts` to satisfy linting rules. Modified Files: - `packages/shared/src/lib/common/activepieces-error.ts` - `packages/server/api/src/app/ee/connection-keys/connection-key.service.ts` - `packages/server/api/src/app/ee/license-keys/license-keys-controller.ts` - `packages/server/api/src/app/app.ts` - `.jules/sentinel.md` (new) Co-authored-by: AGI-Corporation <186229839+AGI-Corporation@users.noreply.github.com>
There was a problem hiding this comment.
π§Ή Nitpick comments (1)
packages/server/api/src/app/app.ts (1)
254-255: Guard origin resolution to avoid 500s in redirect flow.
Line 254 and Line 255 can throw (platform lookup / URL parsing). In that case,/redirectfails hard instead of returning a controlled response.Proposed hardening
- const platformId = await platformUtils.getPlatformIdForRequest(request) - const targetOrigin = new URL(await domainHelper.getPublicUrl({ platformId })).origin - return reply - .type('text/html') - .send( - `<script>if(window.opener){window.opener.postMessage({ 'code': '${encodeURIComponent( - params.code, - )}' }, '${targetOrigin}')}</script> <html>Redirect successfully, this window should close now</html>`, - ) + try { + const platformId = await platformUtils.getPlatformIdForRequest(request) + const publicUrl = await domainHelper.getPublicUrl({ platformId }) + const targetOrigin = new URL(publicUrl).origin + return reply + .type('text/html') + .send( + `<script>if(window.opener){window.opener.postMessage({ 'code': '${encodeURIComponent( + params.code, + )}' }, '${targetOrigin}')}</script> <html>Redirect successfully, this window should close now</html>`, + ) + } + catch (error) { + request.log.warn({ error }, 'Failed to resolve redirect target origin') + return reply.code(400).send('Unable to resolve redirect origin') + }Also applies to: 261-261
π€ Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/server/api/src/app/app.ts` around lines 254 - 255, The platform lookup and URL parsing calls (platformUtils.getPlatformIdForRequest and domainHelper.getPublicUrl, used to compute targetOrigin) can throw and currently cause a 500 in the /redirect flow; wrap the platformId retrieval and URL parsing in a try/catch, log the error, and return a controlled response from the redirect handler (e.g., a safe redirect or a 4xx/302 fallback) instead of allowing the exception to propagate; apply the same guard around the later usage at the block referencing the same domainHelper.getPublicUrl call (the code around line 261) so targetOrigin resolution failures are consistently handled.
π€ Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/server/api/src/app/app.ts`:
- Around line 254-255: The platform lookup and URL parsing calls
(platformUtils.getPlatformIdForRequest and domainHelper.getPublicUrl, used to
compute targetOrigin) can throw and currently cause a 500 in the /redirect flow;
wrap the platformId retrieval and URL parsing in a try/catch, log the error, and
return a controlled response from the redirect handler (e.g., a safe redirect or
a 4xx/302 fallback) instead of allowing the exception to propagate; apply the
same guard around the later usage at the block referencing the same
domainHelper.getPublicUrl call (the code around line 261) so targetOrigin
resolution failures are consistently handled.
βΉοΈ Review info
βοΈ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: bdc16a0b-046f-4a05-b2d7-56d145db4948
π Files selected for processing (1)
packages/server/api/src/app/app.ts
π¨ Severity: HIGH
π‘ Vulnerability: Sensitive Data Leakage in Error Responses
π― Impact: JWT tokens and License Keys were being included in the
paramsofActivepiecesError, which the global backend error handler serializes directly into API responses. This could lead to credential exposure in logs or to unauthorized parties.π§ Fix:
InvalidJwtTokenErrorParamsandInvalidLicenseKeyParamsinpackages/shared/src/lib/common/activepieces-error.tsto exclude sensitive fields.ActivepiecesErrorinconnection-key.service.tsandlicense-keys-controller.tsto remove the sensitive values from parameters.β Verification:
npx eslintpasses for the modified files.read_filethat the changes were correctly applied.pnpm-lock.yamlfile is included in the PR.PR created automatically by Jules for task 7009615417473966508 started by @AGI-Corporation
Summary by CodeRabbit
Bug Fixes
Documentation