{"success":true,"name":"never-eval-or-unsafely-deserialize-data-you-didn-t-create","description":"About to parse, eval, or deserialize content that came from users or outside","category":"ai-brimind","path":"ai-brimind/never-eval-or-unsafely-deserialize-data-you-didn-t-create/SKILL.md","file":"SKILL.md","content":"---\nname: never-eval-or-unsafely-deserialize-data-you-didn-t-create\ndescription: \"About to parse, eval, or deserialize content that came from users or outside\"\n---\n\n# Never Eval or Unsafely Deserialize Data You Didn't Create\n\n## When to use\nThe code takes external content (user input, uploaded config, API response, queue message) and feeds it into eval, a template engine, or a powerful deserializer.\n\n## Example request\nUsing eval to parse a user's formula or JSON-like string → eval runs whatever code the string contains; safe parsers like JSON.parse exist for data (code execution via eval). Loading user-provided YAML with a full-featured loader → some YAML loaders can construct objects and run logic; use the safe-load variant (unsafe deserialization). Passing user text into a server-side template string → template engines can evaluate expressions, letting input become code (server-side template injection). Deserializing objects from a queue or cookie with a binary format → whoever writes that data can craft objects that execute on load; sign the data or use plain data formats (untrusted object streams).\n\n## Instructions\nAct like a developer who knows the difference between parsing data and executing code, and refuses to let outsiders cross that line. Whenever external content must be interpreted, name the mechanism you are about to use and ask: can this mechanism do more than produce plain data — can it construct objects, call functions, or evaluate expressions? If yes, it is a code-execution engine wearing a parser costume, and untrusted input must not reach it: replace eval and Function-from-string with real parsers, use the documented safe mode of YAML/XML loaders, keep user text out of template expressions by passing it as escaped variables only, and prefer boring formats like JSON parsed with the standard parser for anything crossing a trust boundary. When a message truly must round-trip through your system (cookies, queues, tokens), either keep it plain data validated by a schema, or sign it so only your server can produce accepted values. If a library's parsing behavior is unclear, read its security notes before using it on external input, or choose a simpler format. Only proceed once every external-content path uses a data-only parser or verified-origin data, and explain why the choice removes the 'input becomes code' class of attacks rather than just parsing today's examples correctly.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #580\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}