Skip to content

Conversation

@github-actions
Copy link
Contributor

This is an automated pull request to release the candidate branch into production, which will trigger a deployment.
It was created by the [Production PR] action.

* Documentation edits made through Mintlify web editor

* Documentation edits made through Mintlify web editor

---------

Co-authored-by: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com>
@vercel
Copy link

vercel bot commented Oct 27, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
app (staging) Ready Ready Preview Comment Oct 27, 2025 11:21pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
portal (staging) Skipped Skipped Oct 27, 2025 11:21pm

@comp-ai-code-review
Copy link

comp-ai-code-review bot commented Oct 27, 2025

Comp AI - Code Vulnerability Scan

Analysis in progress...

Reviewing 30 file(s). This may take a few moments.


Powered by Comp AI - AI that handles compliance for you | Reviewed Oct 27, 2025, 11:18 PM

* Documentation edits made through Mintlify web editor

* Documentation edits made through Mintlify web editor

* Documentation edits made through Mintlify web editor

---------

Signed-off-by: Mariano Fuentes <marfuen98@gmail.com>
Co-authored-by: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com>
Co-authored-by: Mariano Fuentes <marfuen98@gmail.com>
github-actions bot and others added 2 commits October 27, 2025 19:03
* feat(automation): add evaluation criteria and status to automations

* feat(automation): update button styles based on test state

* chore(hooks): enable revalidation on focus and add deduping interval

* refactor(automation): redesign TestResultsPanel layout and enhance functionality

* refactor(automation): update TestResultsPanel with new button and layout enhancements

* refactor(automation): add fail state icon and update test completion message

* refactor(docs): update README with detailed setup instructions and env variables

* fix(tasks): add 'failed' status to task statuses and update indicators

* chore(db): update @trycompai/db package version to 1.3.15

* refactor(types): replace inline types with Policy and Task interfaces

---------

Co-authored-by: Mariano Fuentes <marfuen98@gmail.com>
@vercel vercel bot temporarily deployed to staging – portal October 27, 2025 23:18 Inactive
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ Marfuen
❌ github-actions[bot]
You have signed the CLA already but the status is still pending? Let us recheck it.

@comp-ai-code-review
Copy link

comp-ai-code-review bot commented Oct 27, 2025

🔒 Comp AI - Security Review

🔴 Risk Level: HIGH

Hardcoded credentials in repo (DATABASE_URL postgres:postgres, frontend token, README secrets) and multiple unvalidated orgId usages enabling IDOR/SQL-injection and cross-org updates.


📦 Dependency Vulnerabilities

✅ No known vulnerabilities detected in dependencies.


🛡️ Code Security Analysis

View 18 file(s) with issues

🔴 README.md (HIGH Risk)

# Issue Risk Level
1 README instructs hard-coding Google OAuth secrets in source HIGH
2 README instructs hard-coding Upstash Redis URL/TOKEN in source HIGH
3 Default Postgres credentials 'postgres/postgres' disclosed HIGH
4 Advice to hard-code env values if .env fails (encourages secrets in repo) HIGH
5 psql command with password in URL exposes creds in shell history HIGH
6 Trigger.dev project ID shown and may be committed to repo HIGH

Recommendations:

  1. Remove any instructions that recommend hard-coding secrets into source files. Instead, document use of environment variables and secret management systems (Vault, AWS/GCP/Azure Secrets Manager, GitHub Actions secrets).
  2. Ensure .env files and any files that may contain secrets are listed in .gitignore and add guidance to never commit them. Provide sample .env.example without real secrets.
  3. Replace guidance to 'hard-code' with deterministic troubleshooting steps (e.g., verify env loading order, process manager config). If necessary, show how to load env files locally (dir/file paths) rather than embedding secrets in code.
  4. Rotate default Postgres credentials and make clear that the 'postgres/postgres' credentials are only for disposable local dev containers. Document how to set a strong password and update the docker/dev env accordingly.
  5. Avoid including passwords on the psql CLI URL. Recommend using .pgpass, environment variable PGPASSWORD, or prompting for the password. Example: psql -h localhost -U postgres -d comp (enter password at prompt) or export PGPASSWORD before running commands in ephemeral shells.
  6. Treat third-party project IDs and API keys as secrets. Remove real Trigger.dev project IDs or mask them in the repo. If a secret/project id has been committed, rotate/regenerate it and remove it from history (git filter-repo or BFG) if it was sensitive.
  7. Add a short 'Handling Leaked Secrets' section: steps to rotate keys, revoke tokens, and remove commits containing secrets from history.
  8. Provide examples for secure local development: using a local secret store (direnv, git-crypt), docker secrets, or injecting secrets at runtime rather than checking them into source.

🔴 apps/app/.env.example (HIGH Risk)

# Issue Risk Level
1 Hardcoded DB creds in DATABASE_URL (postgres:postgres) HIGH
2 Empty critical secrets: AUTH_SECRET, SECRET_KEY, TRIGGER_SECRET_KEY, REVALIDATION_SECRET HIGH

Recommendations:

  1. DATABASE_URL: Remove the hardcoded credentials from the example file. Replace with a placeholder (e.g., postgresql://<DB_USER>:<DB_PASS>@localhost:5432/<DB_NAME>) so no real credentials are committed. If those credentials were ever used in a running environment, rotate the DB password immediately and ensure production DB uses a unique, least-privilege user.
  2. Secrets: Do not store real secrets in repo or example files. Require strong, random values for AUTH_SECRET, SECRET_KEY, TRIGGER_SECRET_KEY, and REVALIDATION_SECRET in deployment. Use a secrets manager (AWS Secrets Manager, HashiCorp Vault, Vercel/Netlify environment vars, etc.) and make the application fail-fast when required secrets are missing.
  3. Access controls: Restrict DB access by network/firewall rules, use private subnets or IP whitelisting, and enforce least privilege for DB users and service accounts.
  4. CI/CD & rotation: Ensure CI/CD and deployment environments inject secrets at runtime, regularly rotate credentials, and audit access to secrets.
  5. Audit committed history: If any real credentials were ever committed to the repo (even in example files), run a repo secret scan and rotate/replace leaked credentials. Consider rewriting history or invalidating leaked tokens.
  6. NEXT_PUBLIC_ and missing API keys (contextual guidance): NEXT_PUBLIC_* environment variables are intentionally exposed to client bundles in Next.js. In this file they are either empty or set to localhost and do not contain secrets. Ensure no sensitive values are placed in NEXT_PUBLIC_* variables. The missing API keys (OPENAI_API_KEY, RESEND_API_KEY, GROQ_API_KEY, FIRECRAWL_API_KEY) in an example file are placeholders and not a security exposure — still ensure real API keys are provisioned only in secure secret stores and never committed to source.

🟡 apps/app/src/app/(app)/[orgId]/frameworks/components/ToDoOverview.tsx (MEDIUM Risk)

# Issue Risk Level
1 Client-side auth check for publish action can be bypassed MEDIUM
2 Unvalidated organizationId passed to publish action MEDIUM

Recommendations:

  1. Enforce authorization on the server-side for the publish endpoint (do not trust client-side isOwner checks). Verify current user's membership/role for the organization on the server before performing publish.
  2. Validate and sanitize organizationId server-side. Ensure the endpoint checks that organizationId matches an organization the authenticated user may operate on (e.g., belongs to user, has required role).
  3. Validate policy/task IDs and other identifiers on the server before acting on them. Do not rely on the client to provide well-formed or authorized IDs.
  4. Avoid relying on client-side role checks for access control. Use them only to conditionally render UI; always perform authoritative checks server-side.
  5. Fix loading state handling: wait for publish action completion (or tie loading state to the action's lifecycle) before clearing isLoading. Currently handleConfirmAction sets isLoading(false) in finally immediately after triggering the async action, which can hide in-progress state and mask errors.

🔴 apps/app/src/app/(app)/[orgId]/frameworks/lib/getPolicies.ts (HIGH Risk)

# Issue Risk Level
1 No authorization check: organizationId used without verifying caller access HIGH
2 No input validation: organizationId accepted and used directly in DB query HIGH
3 Potential injection risk: orgId passed into DB query without sanitization HIGH
4 Sensitive data exposure: returns full draft/policies including unpublished data HIGH
5 Over-fetching: findMany likely returns all fields instead of required ones HIGH

Recommendations:

  1. Enforce authorization: ensure the caller is authenticated and authorized for the provided organizationId (e.g., check current user's org memberships/roles before querying).
  2. Validate organizationId before use: assert expected format (e.g., UUID) and reject/normalize invalid values.
  3. Return the minimum data required: in the findMany call, select only needed fields (or return counts) rather than full policy objects, especially for draft/unpublished policies.
  4. Restrict access to unpublished data: only allow fetching draft/needs_review policies for privileged roles (admins, editors) and never for anonymous or unrelated org members.
  5. Use ORM query selectors and parameterized APIs (avoid string-building). Add input validation layers so even if an ORM parameterizes queries, invalid inputs are rejected early.
  6. Add audit logging for accesses to unpublished/sensitive policy data and consider rate-limiting or additional checks for cross-org access patterns.

🔴 apps/app/src/app/(app)/[orgId]/frameworks/lib/getTasks.ts (HIGH Risk)

# Issue Risk Level
1 Missing authorization check: orgId used without access control HIGH
2 Direct use of organizationId in DB query without validation HIGH
3 Cache may leak organization data between callers HIGH
4 Returning full task objects may expose sensitive fields HIGH
5 Possible SQL injection if ORM not parameterized for orgId HIGH

Recommendations:

  1. Enforce authorization: verify the caller is permitted to access the given organizationId before performing the DB query (use request/user context or an auth middleware).
  2. Validate organizationId before use (e.g., enforce UUID format or check against known organization IDs) and use strong typing for IDs.
  3. Limit returned fields: use the ORM's select/projection to return only the fields required by the caller rather than returning full task objects.
  4. Make caching tenant-aware or avoid cross-tenant caching: include user/org auth context in the cache key or disable server-side cache for tenant-scoped data.
  5. Avoid raw SQL; ensure ORM queries are used correctly (parameterized). If raw queries are used anywhere, convert to parameterized/prepared statements and never concatenate user input into SQL.

🔴 apps/app/src/app/(app)/[orgId]/settings/secrets/components/EditSecretDialog.tsx (HIGH Risk)

# Issue Risk Level
1 Trusting orgId from URL path (window.location.pathname) HIGH
2 User inputs (value/description/category) sent without strict validation HIGH
3 No CSRF token on state-changing fetch HIGH
4 Server error details may be reflected to UI HIGH
5 Secret value sent in JSON could be logged or exposed HIGH

Recommendations:

  1. Do not rely on client-provided orgId for authorization. Derive organization context server-side from the authenticated session/token and verify that the authenticated user is authorized for the target org. Remove or ignore client-sent organizationId on the server if it does not match server-side context.
  2. Enforce strong server-side validation and sanitization for every field (name, value, description, category). Client-side zod validation helps UX but must not be the only enforcement. Apply length limits, allowed character sets, and allowed category enumerations on the server and reject or canonicalize unexpected inputs.
  3. Add CSRF protections for state-changing endpoints if authentication uses cookies. Options include: require anti-CSRF tokens (double-submit cookie pattern), use SameSite=strict or lax cookies and enforce CORS + require custom authorization headers (e.g., Bearer tokens) for API requests. Ensure the server rejects unsafe cross-origin requests.
  4. Avoid reflecting raw server error/stack details directly to the user. Normalize server-side validation errors into a known shape (field + friendly message) and ensure generic error messages for unexpected failures. Do not send internal stack traces or debugging data in production responses.
  5. Treat secret values as highly sensitive: never log them (even at info/debug level), avoid storing them in browser logs or telemetry, minimize time stored in client memory, and use HTTPS for transport. On the server, ensure secure storage (encryption at rest, access controls) and audit/rotate keys if exposure is suspected.
  6. Consider removing organizationId building logic from the client (window.location.pathname) entirely. If client-side orgId is necessary for UI, keep it separate from authorization logic and always verify server-side.
  7. Where appropriate, use an allowlist for category values (server-side enum validation) rather than accepting arbitrary strings.
  8. Ensure responses containing validation errors follow a minimal schema and that the client maps only known fields; fall back to a generic error message when the response format is unexpected.

🔴 apps/app/src/app/(app)/[orgId]/settings/secrets/components/table/SecretsTable.tsx (HIGH Risk)

# Issue Risk Level
1 IDOR via orgId from URL in GET/DELETE /api/secrets/{id} HIGH
2 Injection risks (SQL/command) via orgId or secretId in /api/secrets/{id} HIGH
3 Missing validation of orgId from window.location.pathname before API call HIGH
4 Client exposes secret values in DOM and clipboard increasing leakage risk HIGH

Recommendations:

  1. Enforce server-side authorization: do not trust organizationId coming from the client (URL or query). Derive orgId from the authenticated session/token on the server and verify the requesting user has access to the secret.
  2. Remove or ignore client-provided organizationId on the server. Use server-side ownership checks (compare secret.ownerOrgId to the authenticated user's orgs). Return 403 for unauthorized access.
  3. Validate and sanitize all inputs on the server (secretId, organizationId). Use strong typing and whitelist patterns (e.g., UUID regex) before using values in any DB queries or commands.
  4. Use parameterized queries / ORM query parameters on the server to eliminate SQL injection risk. Never concatenate req.params/req.query/req.body directly into SQL or shell commands.
  5. Avoid exposing plaintext secrets in the DOM. If secrets must be revealed temporarily: render them only in-memory (avoid storing in global state/long-lived DOM elements), limit reveal duration, and ensure they are not logged.
  6. Avoid automatically copying secrets to the clipboard without an explicit, clearly-labeled user action. Consider warning users and require an additional confirmation for copying secrets.
  7. Log and audit secret retrievals and deletions (who, when, which secret) and add rate-limiting / anomaly detection for secret access endpoints.
  8. Use secure transport (HTTPS) and set appropriate response headers (Content-Security-Policy, Referrer-Policy) to reduce exfiltration risk from the client.
  9. Consider moving secret retrieval to a privileged server endpoint that issues short-lived, purpose-limited tokens for client consumption rather than sending raw secret values to the browser.

🔴 apps/app/src/app/(app)/[orgId]/tasks/[taskId]/automation/[automationId]/actions/task-automation-actions.ts (HIGH Risk)

# Issue Risk Level
1 Console logging request URLs may leak sensitive query params HIGH
2 Returning raw error messages leaks internal details to clients HIGH
3 revalidatePath uses unvalidated headers (referer/x-pathname) HIGH
4 User inputs are forwarded to enterprise API without validation HIGH
5 Uploaded/executed scripts lack validation; risk of XSS or remote code exec HIGH
6 NEXT_PUBLIC_ENTERPRISE_API_URL exposes base URL in client bundles HIGH
7 No per-org authorization checks before calling enterprise API HIGH

Recommendations:

  1. Remove or redact console.log of the full URL (console.log('url', url.toString())). If you need request tracing, log a request id and redact query params before logging.
  2. Never return raw internal error messages to clients. Return generic messages (e.g., 'Internal error') and log full details server-side. For EnterpriseApiError, map status codes to safe user messages where appropriate.
  3. Validate and constrain values used with revalidatePath. Do not rely on Referer/x-pathname headers directly. Maintain a whitelist of allowed paths or map header values to known internal routes before calling revalidatePath. Also canonicalize and ensure path starts with '/' and does not contain '..' or scheme/host.
  4. Validate and sanitize all inputs before forwarding to the enterprise API: enforce types, lengths, allowed characters, and expected formats for orgId, taskId, automationId, keys, offsets, limits, and script content metadata.
  5. Enforce strict validation and scanning of uploaded scripts: restrict allowed file types/extensions and maximum size, perform static analysis/scan for unsafe constructs if these scripts will be executed server-side, and run them in isolated sandboxes with least privilege. If scripts are stored for client-side usage, sanitize outputs to prevent XSS.
  6. Avoid using NEXT_PUBLIC_* env vars for server-only configuration. Use server-only env var names (no NEXT_PUBLIC_) for anything that should not be exposed to client bundles. If base URL must be public, ensure no secrets are derivable from it.
  7. Add per-request authorization checks to ensure the caller is permitted to act on the given orgId/taskId/automationId before calling the enterprise API or performing DB operations. Validate the authenticated user's org membership and roles.
  8. Fix the template string bug in getAutomationRunStatus: the endpoint string currently uses single quotes with ${runId} (literal). Use backticks or append runId properly: /api/tasks-automations/runs/${runId}.
  9. Apply defensive limits and sanity checks for pagination params (offset, limit) and other numeric inputs to avoid resource exhaustion.
  10. Centralize input validation and sanitization (e.g., schema validation with zod/joi) and ensure all server actions pipe input through it before use.

🟡 apps/app/src/app/(app)/[orgId]/tasks/[taskId]/automation/[automationId]/components/evaluation/EvaluationCriteriaCard.tsx (MEDIUM Risk)

# Issue Risk Level
1 Unvalidated user input sent to updateEvaluationCriteria MEDIUM
2 Potential stored XSS if backend stores or renders criteria unsanitized MEDIUM
3 Potential SQL injection if backend interpolates criteria into SQL MEDIUM
4 Potential command injection if backend executes criteria MEDIUM
5 No input size limit; large payloads may enable DoS MEDIUM
6 No CSRF protection shown for update action MEDIUM
7 No client-side auth/authorization checks before update call MEDIUM

Recommendations:

  1. Validate and sanitize criteria on the server; enforce allowed patterns and length
  2. Escape or sanitize criteria when rendering to prevent stored XSS
  3. Use parameterized queries or an ORM to avoid SQL injection
  4. Never exec shell commands with raw input; sanitize or reject command-like input
  5. Enforce authentication/authorization, CSRF protection, size limits and rate limits on update endpoint

🟡 apps/app/src/app/(app)/[orgId]/tasks/[taskId]/automation/[automationId]/components/workflow/components/UnifiedWorkflowCard.tsx (MEDIUM Risk)

# Issue Risk Level
1 Hardcoded token in image URL: pk_AZatYxV5QDSfWpRDaBxzRQ MEDIUM
2 Unsanitized integration.link concatenated into image src MEDIUM
3 External image loads can leak referrer/metadata to third parties MEDIUM

Recommendations:

  1. Remove the hardcoded token from the client code. Do not embed long-lived secrets in frontend code. Keep the token in a server-side environment variable and use the server to produce signed/short-lived URLs or proxy requests to img.logo.dev.
  2. Avoid exposing the token to the browser. If client-side access is required, issue short-lived, scoped tokens from the backend per request rather than a permanent key baked into source.
  3. Do not directly interpolate unvalidated input into URL paths. Validate/allowlist integration.link values (e.g., known integration keys or an explicit regex such as ^[a-z0-9-_.]+$), strip/normalize slashes, remove query and fragment characters, and apply encodeURIComponent on any path components before concatenation.
  4. Consider fetching/serving logos via a trusted server-side proxy that validates requests and injects the credential server-side. This prevents leaking tokens and gives control over which external resources are requested.
  5. Set Image referrerPolicy='no-referrer' (Next.js Image supports this prop) and consider crossOrigin='anonymous' where appropriate to avoid sending referrer or credentials to third parties. Also adopt a strict Content Security Policy restricting allowed image sources.
  6. If you must allow dynamic external image domains, ensure you maintain an allowlist and sanitize any user-controlled parts. Log and monitor unusual requests to the logo-serving service.
  7. If using Next.js remotePatterns/domains for next/image configuration, ensure the configured domain(s) are strict and do not permit arbitrary hostnames constructed from user input.

🟡 apps/app/src/app/(app)/[orgId]/tasks/[taskId]/automation/[automationId]/components/workflow/workflow-visualizer-simple.tsx (MEDIUM Risk)

# Issue Risk Level
1 Missing validation of orgId/taskId/automationId from URL used in restore/fetch/execute APIs MEDIUM

Recommendations:

  1. Enforce server-side authorization and validation for all endpoints (restoreVersion, script fetch, execute) — never trust client-provided IDs.
  2. On the server, verify the requesting user has access to the orgId/taskId/automationId before performing actions (restore, execute, fetch). Return 403 if not authorized.
  3. Validate ID formats strictly (e.g., UUID regex or expected numeric pattern) on both client (UX) and server (security). Reject unexpected values early.
  4. Sanitize and canonicalize inputs on the server. Treat URL params as untrusted input.
  5. Add explicit checks on the client to avoid sending obviously invalid values (e.g., undefined, 'new') — but treat this as UX/safety only, not as a security boundary.
  6. Log and audit restore and execution events with actor, timestamp, and parameters to detect abnormal access or abuse.
  7. Use CSRF protections, rate limiting, and monitoring on endpoints that modify state (restore/publish/execute).
  8. Ensure actions invoked from the client (sendMessage, execute, restoreVersion) cannot be used to escalate privileges by tampering with org/task IDs — re-derive or verify ownership server-side.

🟡 apps/app/src/app/(app)/[orgId]/tasks/[taskId]/automation/[automationId]/hooks/use-task-automation-execution.ts (MEDIUM Risk)

# Issue Risk Level
1 No validation of orgId/taskId from route params MEDIUM
2 Unvalidated automationIdRef from shared context MEDIUM
3 Trusting remote API response structure without schema checks MEDIUM
4 Blind polling without max retries or backoff MEDIUM
5 Console.error may log sensitive remote error details MEDIUM
6 Using NEXT_PUBLIC_* exposes endpoint URL publicly MEDIUM

Recommendations:

  1. Validate and sanitize orgId and taskId before using them in API calls. Validate against an expected pattern (e.g., UUID or constrained character set) and reject or normalize invalid values rather than passing them directly to downstream APIs.
  2. Validate automationIdRef.current before use (e.g., ensure it's a non-empty string that matches the expected format). Add defensive checks and fail early with a clear error path rather than calling APIs with invalid IDs.
  3. Add strict runtime schema validation for all remote API responses. Use a validator (zod, io-ts, yup) to parse response.json() and handle unexpected shapes explicitly instead of assuming properties exist. This prevents runtime exceptions and avoids trusting attacker-controlled fields.
  4. Implement polling limits and backoff: add a maximum retry count and use exponential backoff (and jitter) between polls. Also provide a way to cancel polling (AbortController or clearTimeout on unmount) and ensure resources are cleaned up.
  5. Avoid logging full remote error payloads to the browser console. Sanitize or redact sensitive fields before logging and log only what is necessary for debugging. Consider sending detailed errors to a secure server-side logging/observability pipeline instead of the client console.
  6. Do not expose secrets or sensitive endpoints via NEXT_PUBLIC_* environment variables. NEXT_PUBLIC_* values are embedded in client bundles and are public. If the enterprise API URL must be hidden, proxy requests through your server (API routes) or keep non-public config server-side; if it must be client-visible, ensure there are no secrets and enforce server-side ACLs.

🟡 apps/app/src/app/(app)/[orgId]/tasks/[taskId]/automation/[automationId]/hooks/use-task-automation.ts (MEDIUM Risk)

# Issue Risk Level
1 Unvalidated route params used in API path (orgId/taskId/automationId) MEDIUM
2 Unvalidated params can enable server-side injection (SQL/command) on backend MEDIUM
3 Raw error object returned to caller may expose internal info MEDIUM

Recommendations:

  1. Validate and sanitize orgId, taskId, automationId on the client before use (e.g., whitelist/regex for expected format such as UUID) and on the server as authoritative validation.
  2. URL-encode path segments when building request URLs (encodeURIComponent for each path segment) or use an API client helper that safely constructs paths.
  3. Enforce server-side input validation and use parameterized queries / ORM binding to prevent SQL/command injection regardless of client behavior.
  4. Do not propagate raw internal error objects/messages to the UI. Return a generic error message to the client and log full details server-side for troubleshooting.
  5. Use a schema validator (e.g., zod, yup, Joi) at both client boundary and server endpoints to enforce shapes and value constraints for IDs and other params.
  6. Ensure the API client handles and normalizes errors so the hook exposes only sanitized, user-safe error messages and well-defined error codes to consumers.

🟡 apps/app/src/app/(app)/[orgId]/tasks/[taskId]/automations/[automationId]/overview/components/AutomationOverview.tsx (MEDIUM Risk)

# Issue Risk Level
1 Unsanitized description sent to API (stored XSS risk) MEDIUM
2 URL params interpolated into API paths without validation MEDIUM
3 Error messages logged/shown to users may leak internals MEDIUM
4 Client can invoke toggle/delete actions without UI auth gating MEDIUM

Recommendations:

  1. Sanitize and validate description server-side before persisting. Apply output-encoding when rendering descriptions in any context that could interpret HTML. Enforce input length limits and reject overly-large payloads. Consider a server-side HTML sanitizer (e.g., DOMPurify on input or output) and a strict content policy.
  2. Validate and canonicalize orgId/taskId/automationId on the server. Require strong formats (e.g., UUIDs) or lookup/ACL checks rather than trusting path segments. Reject or normalize unexpected characters and length.
  3. Avoid returning raw error.message or stack traces to the client. Return a generic error string (e.g., 'Failed to update description') and log detailed error information only server-side with appropriate correlation IDs. Remove or limit console.error output in production client builds.
  4. Enforce authorization and permission checks on the server for toggle/delete endpoints (check the authenticated user belongs to org and has rights on the task/automation). Implement CSRF protections for state-changing actions. Client-side UI gating is fine for UX but cannot replace server-side auth enforcement.
  5. Add client-side validation for better UX (e.g., length, allowed characters), but treat server-side validation as authoritative. Implement rate-limiting and audit logs for sensitive actions (delete/toggle).
  6. Consider Content Security Policy (CSP) and secure headers on responses to reduce impact of any stored XSS that might occur despite sanitization.

🟡 apps/app/src/app/(app)/[orgId]/tasks/[taskId]/automations/[automationId]/overview/components/MetricsSection.tsx (MEDIUM Risk)

# Issue Risk Level
1 Unvalidated URL params used in API path (orgId/taskId/automationId) MEDIUM
2 User-editable name sent to API without sanitization (injection risk) MEDIUM
3 Possible stored XSS if server stores and later renders automation name MEDIUM
4 Unvalidated editScriptUrl prop used in Link (open navigation risk) MEDIUM

Recommendations:

  1. Treat orgId, taskId, automationId as untrusted input. Validate and canonicalize them on the server side and enforce authorization/ACL checks there. Do not rely on client-side enforcement.
  2. On the server, validate and constrain the name field (length, allowed characters) and perform proper escaping/encoding when persisting or rendering it. Client-side validation may be helpful for UX but must not replace server validation.
  3. Apply output encoding/escaping when rendering automationName anywhere in HTML or templates to prevent stored XSS. Prefer encoding on output (e.g., HTML-escaping) and use libraries/framework facilities for safe rendering.
  4. If editScriptUrl can be influenced by users, restrict it to an internal whitelist or canonicalize it to internal routes only. Validate URLs before rendering them in a Link (ensure scheme is http(s) and host is allowed). Consider forcing internal routing paths rather than arbitrary hrefs.
  5. Use server-side protections: parameterized queries or ORM APIs to prevent injection at data layer; avoid interpolating user input into SQL/commands. Ensure any downstream systems that consume these values also validate and sanitize input.
  6. Consider adding Content Security Policy (CSP) and other defense-in-depth measures to reduce impact of XSS if it were to occur.

🟡 apps/app/src/app/(app)/[orgId]/tasks/[taskId]/components/SingleTask.tsx (MEDIUM Risk)

# Issue Risk Level
1 Unsanitized task updates sent to updateTask MEDIUM
2 Server error text shown directly in toast MEDIUM
3 Client triggers regenerate/delete actions without local auth checks MEDIUM

Recommendations:

  1. Validate and sanitize all task inputs client- and server-side
  2. Do not display raw server errors; show generic messages
  3. Enforce server-side authorization for regenerate/delete/update actions
  4. Escape or sanitize any user-generated HTML before rendering

🔴 apps/app/src/app/(app)/[orgId]/tasks/actions/updateTaskStatus.ts (HIGH Risk)

# Issue Risk Level
1 Update query lacks organizationId filter allowing cross-org task updates HIGH
2 Time-of-check to time-of-use race between find and update HIGH
3 id not validated as UUID or constrained HIGH
4 Console.error may expose sensitive internal error details HIGH

Recommendations:

  1. Include organizationId in the update WHERE clause so the update is authorized for the active org. If your ORM requires a unique identifier, use updateMany with a where that includes both id and organizationId and verify that the updatedCount === 1, or ensure a composite unique constraint exists and use it in the update.
  2. Perform the check-and-update atomically. Options: (a) do a single updateMany({ where: { id, organizationId }, data: { status } }) and check the affected count, or (b) wrap the find + update in a database transaction with appropriate row locking (or use optimistic locking) to avoid TOCTOU races.
  3. Tighten input validation: change id: z.string() to z.string().uuid() (or another stricter constraint matching your DB primary key format) so invalid ids are rejected early.
  4. Avoid logging raw error objects. Normalize or redact error messages before logging (e.g., log a sanitized message plus an internal error id), or use structured logging that excludes sensitive fields. Return generic error messages to the client.
  5. Enforce row-level authorization in the database (policies/row-level security) or ensure the ORM operations always include organizationId constraints so a compromised client cannot update resources in another organization.

🟡 apps/app/src/app/(app)/[orgId]/tasks/components/TaskStatusSelector.tsx (MEDIUM Risk)

# Issue Risk Level
1 Client UI doesn't gate actions by user permissions MEDIUM

Recommendations:

  1. Add client-side gating: hide or disable the status-change control when the current user lacks permission (derive user permissions from the authenticated session/context so the UI does not present actions that will be rejected).
  2. Enforce server-side authorization: in updateTaskStatusAction, verify that the authenticated user has the explicit permission/role to update the task (e.g., check user role/permissions in ctx.session or load the user record and validate). Do not rely solely on organization membership.
  3. Return specific but non-sensitive error codes/messages for authorization failures (e.g., 'not_permitted') so the client can make correct UI decisions without exposing internal details.
  4. Keep input validation on the server (zod nativeEnum is already used) and ensure any future server-side action that mutates data includes both authentication and fine-grained authorization checks.

💡 Recommendations

View 3 recommendation(s)
  1. Remove hardcoded secrets from source: replace values in apps/app/.env.example and README.md with non-sensitive placeholders; remove the hardcoded token (pk_AZatYxV5QDSfWpRDaBxzRQ) from apps/app/.../UnifiedWorkflowCard.tsx. If any committed secrets were used, rotate/regenerate them and remove them from the repository history.
  2. Enforce server-side org scoping and input validation for all org-scoped handlers (getPolicies.ts, getTasks.ts, updateTaskStatus.ts, secrets APIs, etc.). Validate orgId (e.g., z.string().uuid()), derive org membership from authenticated session, include organizationId in DB WHERE clauses (use updateMany or a single atomic update with where: { id, organizationId }) and return 403 when the authenticated user is not authorized.
  3. Eliminate injection and sensitive-data leakage: use ORM parameterized APIs (avoid interpolating orgId/ids into queries/URLs), restrict returned fields (select only required columns, avoid returning unpublished drafts to unauthorized callers), encode path segments (encodeURIComponent) when building URLs, and stop returning raw error objects to clients—map errors to safe messages and log details server-side.

Powered by Comp AI - AI that handles compliance for you. Reviewed Oct 27, 2025

@Marfuen Marfuen merged commit 0ac5bf6 into release Oct 27, 2025
10 of 11 checks passed
@claudfuen
Copy link
Contributor

🎉 This PR is included in version 1.56.4 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants