Back to Skills

security

MUST be used whenever fixing security issues in a Flows app, or before shipping any feature that handles credentials, user input, or external data. This skill finds AND fixes security problems — it does not just report them. Do NOT skip this when the user asks for a security fix, security hardening, or vulnerability remediation — run every step in order. Triggers: security, security fix, security hardening, vulnerability, XSS, injection, credentials, secrets, auth, authentication, authorization,

5stars1forksUpdated 6/29/2026

Security Assessment

Safe(100/100)

Detected risks:

Agent-reviewed override(Security best-practices guide: eval()/new Function() appear as patterns to AVOID (rewrite data-driven; DOMPurify for XSS); private_key/token/API_KEY/.env are guidance on handling secrets safely. Describes insecure patterns, does not use them.)
Security Score100/100

About security

A security remediation workflow for Cognite Flows apps that both finds and fixes issues rather than only reporting them. It is meant to run before shipping any feature that handles credentials, user input, or external data, and to be invoked for security fixes, hardening, or vulnerability remediation. An optional argument scopes the audit to a file or directory; with no argument it audits the whole app. Every step that finds a problem is expected to also fix it, and the steps are run in order.

The workflow begins by mapping the attack surface, reading entry and routing files (src/main.tsx, src/App.tsx), the Vite config, package.json, and any auth, login, token, or credential files, then identifying which routes are behind an auth guard and where external data enters or is written back. Subsequent steps each pair a search with a concrete fix: migrating any raw HTTP, WebSocket, axios, or fetch calls that target CDF-like hosts onto the official Cognite SDK (and removing custom Authorization or api-key headers, since the SDK handles auth); replacing hard-coded secrets with import.meta.env.VITE_* references, adding placeholders to .env.example, and ensuring .env and .env.local are gitignored; neutralizing dangerous DOM APIs by wrapping dangerouslySetInnerHTML with DOMPurify.sanitize() and rewriting eval, new Function, and string-argument setTimeout/setInterval.

Later steps close authentication and authorization gaps (every route showing CDF data must sit behind the Flows auth guard so useCogniteClient returns a non-null sdk, clients must use short-lived OIDC tokens rather than static API keys, and capability checks must happen server-side via CDF ACLs), with specific guidance for the Atlas chat integration: agentExternalId must not be built from user input, and tool execute functions must validate args before using them in queries. Input validation gaps are addressed by adding runtime validation (installing Zod if absent and using safeParse instead of type casts) for values arriving from forms, URL params, or query strings. Concrete grep commands and before/after code snippets are provided throughout to drive each fix.

FAQ

Does this skill only report security issues or does it fix them?

It finds and fixes them. Every step that finds an issue is expected to apply the fix directly, with before/after code examples provided for each pattern.

How does it handle raw network calls to CDF?

It searches for fetch, axios, XMLHttpRequest, and similar calls to CDF-like hosts and rewrites them to use the official Cognite SDK, then removes any custom Authorization or api-key headers since the SDK handles auth automatically.

What does it do about hard-coded secrets?

Each hard-coded secret is replaced with an import.meta.env.VITE_* reference, a placeholder is added to .env.example, and .env and .env.local are added to .gitignore if missing. It also removes console logging of tokens or keys.

How are XSS and code-injection risks addressed?

dangerouslySetInnerHTML values are wrapped with DOMPurify.sanitize(), and eval, new Function, or string-argument setTimeout/setInterval calls are rewritten to data-driven or function-reference forms. DOMPurify is installed if needed.

What validation library does it use for untrusted input?

It uses Zod, installing it if not present, and recommends defining a schema and calling safeParse on values from forms, URL params, or query strings instead of using type casts.

Install security

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill