agentsclimarketplace

Openai sdk security scan

Skill Dolphinllc/claude-security-skills/skills/defensive/genai/openai-sdk-security-scan

Defensive security skills for Claude Code and the Claude Agent SDK — web applications and generative AI systems.

Install
npx -y skills add Dolphinllc/claude-security-skills --skill openai-sdk-security-scan

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Defensive security scan for code using the OpenAI SDK (openai Python, openai Node). Detects API keys in client bundles, function-calling handlers without argument validation, missing structured-output schema, untrusted attachments fed to vision/Assistants, model output rendered as HTML, and verbose logging of full prompts. Invoke when the user asks to "review", "audit", or "scan" code that calls openai.chat.completions, responses, or assistants APIs.

SKILL.md

5.7 KB, as published. Nobody here has run it

OpenAI SDK Security Scan

Defensive scan for applications using the OpenAI SDK. Reports findings using the shared scoring schema.

Scope

  • Files importing openai (Python) or openai (Node)
  • Calls to chat.completions.create, responses.create, beta.assistants.*, beta.threads.*
  • Function/tool definitions and dispatch handlers

Rules

IDSeverityDetectionFix
OAI-KEY-001criticalnew OpenAI({ apiKey: ... }) reads NEXT_PUBLIC_* / VITE_* / runs in client-side bundleMove calls behind a server route; never ship the key
OAI-KEY-002highHardcoded sk-... key literal in sourceMove to env; rotate immediately
OAI-INJ-001highUser-controlled document content in a user message without delimiter / data-vs-instruction framingWrap in tagged block (<doc>...</doc>) and instruct the model to treat as data
OAI-INJ-002highTool/function result returned to the model unsanitized while agent has high-privilege toolsTreat tool results as untrusted; require confirmation for irreversible actions
OAI-FN-001criticalFunction-call handler executes shell / SQL / fs from tool_calls[i].function.arguments without parsing+validating against the declared parameters schemaParse with JSON.parse then validate with zod/Pydantic against the same schema you advertised
OAI-FN-002highFunction declared with additionalProperties: true (or omitted) on input schemaSet additionalProperties: false; enumerate required fields
OAI-FN-003mediumMultiple high-impact tools registered without tool_choice constraints in agent loopsConstrain tool_choice per step; consider explicit per-step planner
OAI-OUT-001criticalModel output passed to eval / exec / Function() / subprocess.run(shell=True) / direct SQLParse into a structured schema and dispatch via allowlisted code paths
OAI-OUT-002highModel output rendered with dangerouslySetInnerHTML / v-html / innerHTMLRender as text or sanitize
OAI-STRUCT-001mediumCode parses model output expecting JSON without using response_format: { type: "json_schema", strict: true } (or response_format: { type: "json_object" })Use Structured Outputs with strict schema; validate the result anyway
OAI-VISION-001highImage URL in image_url content block fetched from user-supplied URL with no allowlistAllowlist hosts; or download server-side, validate MIME/size, re-upload
OAI-ASST-001highAssistants API thread shared across users (single thread id reused for many tenants)One thread per user/session; never cross-tenant
OAI-ASST-002highFile uploaded via files.create from user input without size/MIME/AV checkValidate before upload; tag with tenant id
OAI-MOD-001mediumOutput rendered in a public-facing UI without consulting moderations / safety classifierRun user input through moderation for safety-critical surfaces; log decisions
OAI-LOG-001mediumFull messages / input / output logged at info level in productionLog request id and token counts; redact bodies
OAI-RETRY-001lowCustom retry loop without backoff on 429/5xx (DoS amplification)Use SDK built-in retry or exponential backoff

Wrong vs. right

OAI-FN-001 (unvalidated function args)

# ❌ Direct execution
args = json.loads(tool_call.function.arguments)
subprocess.run(args["command"], shell=True)
# ✅ Schema-validated + allowlisted
from pydantic import BaseModel
from typing import Literal

class RunArgs(BaseModel):
    command: Literal["build", "test", "lint"]

args = RunArgs.model_validate_json(tool_call.function.arguments)
spawn_allowlisted(args.command)

OAI-STRUCT-001 (no structured output)

// ❌ Hope the model returns JSON
const completion = await client.chat.completions.create({
  model: "gpt-4.1",
  messages: [...],
});
const data = JSON.parse(completion.choices[0].message.content!);
// ✅ Strict schema enforcement
const completion = await client.chat.completions.create({
  model: "gpt-4.1",
  messages: [...],
  response_format: {
    type: "json_schema",
    json_schema: {
      name: "extract",
      strict: true,
      schema: {
        type: "object",
        additionalProperties: false,
        required: ["email", "score"],
        properties: {
          email: { type: "string", format: "email" },
          score: { type: "integer", minimum: 0, maximum: 100 },
        },
      },
    },
  },
});

OAI-ASST-001 (cross-tenant thread)

// ❌ Single shared thread
const thread = await client.beta.threads.create();  // module-level
// later: every user posts to thread.id
// ✅ One thread per session
const threadId = await getOrCreateThreadForUser(userId);

References

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.