Loading...
Loading...
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, token, sensitive data, input validation, CORS, CSP, dependency audit.
npx skill4agent add cognitedata/builder-skills securitysrc/main.tsxsrc/App.tsxvite.config.tspackage.json**/auth***/login***/token***/credential*fetchfetch# Find fetch, axios, XMLHttpRequest, and other HTTP client usage
grep -rn --include="*.ts" --include="*.tsx" --include="*.js" \
-E "(fetch\(|axios\.|axios\(|XMLHttpRequest|\.ajax\(|http\.get\(|http\.post\(|request\()" src/
# Find raw URL construction that looks like CDF endpoints
grep -rn --include="*.ts" --include="*.tsx" \
-E "(cognitedata\.com|cognite\.ai|/api/v1/projects|cdf\.|\.cognite\.)" src/
# Find custom Authorization or api-key headers
grep -rn --include="*.ts" --include="*.tsx" \
-E "(Authorization|api-key|apikey|x-api-key)" src/ | grep -v "node_modules"| Pattern | Action |
|---|---|
| Rewrite to use the Cognite SDK ( |
Custom | Remove — the SDK handles auth automatically |
| WebSocket connection to CDF endpoints | Rewrite to use SDK streaming methods |
| Proxy endpoint that forwards to CDF internally | Rewrite the proxy to use the SDK internally |
| Leave — but add a comment documenting why it's needed |
axiosfetchsdk.files.*sdk.timeseries.*client.instances.*# Look for anything that smells like a secret in source files
grep -rn --include="*.ts" --include="*.tsx" --include="*.js" \
-E "(password|secret|apikey|api_key|token|bearer|private_key)\s*=\s*['\"]" src/.env.example.env.gitignoreimport.meta.env.VITE_*const apiKey = "sk-abc123"const apiKey = import.meta.env.VITE_API_KEYconst token = "eyJhbG..."const token = import.meta.env.VITE_AUTH_TOKEN.env.exampleVITE_API_KEY=your-api-key-here.env.example.env.env.local.gitignoreconsole.logconsole.errorgrep -rn --include="*.tsx" --include="*.ts" \
-E "dangerouslySetInnerHTML|innerHTML\s*=|eval\(|new Function\(|setTimeout\(['\"]|setInterval\(['\"]" src/pnpm add dompurifypnpm add -D @types/dompurifydangerouslySetInnerHTMLDOMPurify.sanitize()import DOMPurify from 'dompurify'// Before
<div dangerouslySetInnerHTML={{ __html: userContent }} />
// After
import DOMPurify from 'dompurify';
<div dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(userContent) }} />eval()new Function()JSON.parse()setTimeoutsetInterval// Before
setTimeout("doSomething()", 1000)
// After
setTimeout(() => doSomething(), 1000)src/contexts/src/hooks/setup-flows-authuseCogniteClientsdkuseAtlasChatagentExternalIdexecuteargsuseCogniteClientexecuteargs# Find useSearchParams, URLSearchParams, and form onChange handlers
grep -rn --include="*.tsx" --include="*.ts" \
-E "useSearchParams|URLSearchParams|searchParams\.get|e\.target\.value" src/pnpm add zod.safeParse()import { z } from 'zod';
const paramSchema = z.object({
id: z.string().min(1),
page: z.coerce.number().int().positive().default(1),
});
const result = paramSchema.safeParse({ id: searchParams.get('id'), page: searchParams.get('page') });
if (!result.success) { /* handle error */ }as MyType.safeParse()searchParams.get()vite.config.tsserver.tsexpress.tsvite.config.tsserver.headersserver: {
headers: {
'Content-Security-Policy': "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; connect-src 'self' https://*.cognitedata.com",
'X-Frame-Options': 'DENY',
'X-Content-Type-Options': 'nosniff',
},
}Content-Security-Policydefinevite.config.tsimport.meta.envserver.proxypnpm audit --audit-level=highpnpm audit fixpackage.jsonpnpm install| Step | What was fixed | Remaining issues |
|---|---|---|
| 2 — CDF SDK | Migrated N raw calls to SDK | (any that couldn't be migrated) |
| 3 — Credentials | Replaced N hardcoded secrets with env vars | (any that need human decision) |
| 4 — DOM | Sanitized N dangerous patterns | (any that need refactoring) |
| 5 — Auth | Wrapped N unguarded routes | (any architectural gaps) |
| 6 — Validation | Added Zod schemas to N inputs | (any that need custom logic) |
| 7 — Vite config | Added N security headers | (any CSP tuning needed) |
| 8 — Dependencies | Fixed N vulnerable packages | (any with no available fix) |