[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M69AJ1ASRSCJ90HDWN05TW82":3,"skill-same:01M69AJ1ASRSCJ90HDWN05TW82":68},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":44,"commitSha":45,"skillDirectory":46,"forksCount":47,"repositoryHtmlUrl":48,"repositoryHomepageUrl":49,"ownerHtmlUrl":50,"ownerBlogUrl":51,"ownerDescription":52,"updatedAt":53,"install":54,"resources":67},"01M69AJ1ASRSCJ90HDWN05TW82","python-kwargs-setattr-security",null,"When reviewing or fixing Python code that uses setattr() with user-controlled kwargs to configure C++ extension objects (SessionOptions, RunOptions, etc.) in ONNX Runtime. Use this to apply the allowlist pattern that prevents arbitrary file writes and other attacks via reflected property access.","microsoft\u002Fonnxruntime","microsoft","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6154722?v=4","01M698VYDXZ6JW5WH3CRV650R8","Microsoft","01M69AGY0EW9AJXAH7HK223SQZ",22286,"MIT","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fonnxruntime\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fpython-kwargs-setattr-security\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"security","python","python kwargs setattr security","when","apply","python code","attacks","with","via","extension","runtime","c++","pattern","objects","use","configure","access","file","code","onnx","2026-11-10 10:12:30",false,"---\nname: python-kwargs-setattr-security\ndescription: When reviewing or fixing Python code that uses setattr() with user-controlled kwargs to configure C++ extension objects (SessionOptions, RunOptions, etc.) in ONNX Runtime. Use this to apply the allowlist pattern that prevents arbitrary file writes and other attacks via reflected property access.\n---\n\n## Problem Pattern\n\nUsing `hasattr(obj, k) \u002F setattr(obj, k, v)` with user-controlled kwargs is insecure. The `hasattr` check is NOT a security guard — it returns True for ALL exposed properties including dangerous ones.\n\n```python\n# INSECURE — do not use\nfor k, v in kwargs.items():\n    if hasattr(options, k):\n        setattr(options, k, v)\n```\n\n## Fix: Explicit Allowlist\n\nDefine a module-level frozenset of safe attribute names. Raise RuntimeError for known-but-blocked attrs; silently ignore unknown keys.\n\n```python\n# Define at module level, before the class\n_ALLOWED_SESSION_OPTIONS = frozenset({\n    \"enable_cpu_mem_arena\",\n    \"enable_mem_pattern\",\n    # ... only explicitly reviewed safe attrs\n})\n\n# In the method\nfor k, v in kwargs.items():\n    if k in _ALLOWED_SESSION_OPTIONS:\n        setattr(options, k, v)\n    elif hasattr(options, k):  # reuse the existing instance, don't create new\n        raise RuntimeError(\n            f\"SessionOptions attribute '{k}' is not permitted via the backend API. \"\n            f\"Allowed attributes: {', '.join(sorted(_ALLOWED_SESSION_OPTIONS))}\"\n        )\n    # else: silently ignore (may be kwargs for a different config object)\n```\n\n## Key Rules\n\n1. **Use the existing object** in `hasattr(options, k)` — never `hasattr(ClassName(), k)` (creates throwaway C++ objects per iteration)\n2. **RuntimeError** is the ORT convention for API misuse errors (not ValueError)\n3. **Silent ignore for one path is OK when kwargs are forwarded to both paths**: `run_model()` passes the same kwargs dict to both `prepare()` (validates SessionOptions) and `rep.run()` (validates RunOptions). A RunOptions kwarg unknown to SessionOptions is silently ignored by `prepare()` — this is correct because `rep.run()` will validate it. Only raise RuntimeError when the attr exists on the target object but is blocked.\n4. **Frozenset constant naming**: `_ALLOWED_\u003CCLASSNAME>` — ALL_CAPS, Google Style\n5. **No type annotations** on module-level constants (ORT Python convention)\n\n## Dangerous SessionOptions Properties (never allowlist)\n\n- `optimized_model_filepath` — triggers Model::Save(), overwrites arbitrary files\n- `profile_file_prefix` + `enable_profiling` — writes profiling JSON to arbitrary path\n- `register_custom_ops_library` — loads arbitrary shared libraries (method, not property)\n\n## Files in ONNX Runtime\n\n- `onnxruntime\u002Fpython\u002Fbackend\u002Fbackend.py` — `_ALLOWED_SESSION_OPTIONS`\n- `onnxruntime\u002Fpython\u002Fbackend\u002Fbackend_rep.py` — `_ALLOWED_RUN_OPTIONS`\n- Tests: `onnxruntime\u002Ftest\u002Fpython\u002Fonnxruntime_test_python_backend.py` — `TestBackendKwargsAllowlist`\n","## Problem Pattern\n\nUsing `hasattr(obj, k) \u002F setattr(obj, k, v)` with user-controlled kwargs is insecure. The `hasattr` check is NOT a security guard — it returns True for ALL exposed properties including dangerous ones.\n\n```python\n# INSECURE — do not use\nfor k, v in kwargs.items():\n    if hasattr(options, k):\n        setattr(options, k, v)\n```\n\n## Fix: Explicit Allowlist\n\nDefine a module-level frozenset of safe attribute names. Raise RuntimeError for known-but-blocked attrs; silently ignore unknown keys.\n\n```python\n# Define at module level, before the class\n_ALLOWED_SESSION_OPTIONS = frozenset({\n    \"enable_cpu_mem_arena\",\n    \"enable_mem_pattern\",\n    # ... only explicitly reviewed safe attrs\n})\n\n# In the method\nfor k, v in kwargs.items():\n    if k in _ALLOWED_SESSION_OPTIONS:\n        setattr(options, k, v)\n    elif hasattr(options, k):  # reuse the existing instance, don't create new\n        raise RuntimeError(\n            f\"SessionOptions attribute '{k}' is not permitted via the backend API. \"\n            f\"Allowed attributes: {', '.join(sorted(_ALLOWED_SESSION_OPTIONS))}\"\n        )\n    # else: silently ignore (may be kwargs for a different config object)\n```\n\n## Key Rules\n\n1. **Use the existing object** in `hasattr(options, k)` — never `hasattr(ClassName(), k)` (creates throwaway C++ objects per iteration)\n2. **RuntimeError** is the ORT convention for API misuse errors (not ValueError)\n3. **Silent ignore for one path is OK when kwargs are forwarded to both paths**: `run_model()` passes the same kwargs dict to both `prepare()` (validates SessionOptions) and `rep.run()` (validates RunOptions). A RunOptions kwarg unknown to SessionOptions is silently ignored by `prepare()` — this is correct because `rep.run()` will validate it. Only raise RuntimeError when the attr exists on the target object but is blocked.\n4. **Frozenset constant naming**: `_ALLOWED_\u003CCLASSNAME>` — ALL_CAPS, Google Style\n5. **No type annotations** on module-level constants (ORT Python convention)\n\n## Dangerous SessionOptions Properties (never allowlist)\n\n- `optimized_model_filepath` — triggers Model::Save(), overwrites arbitrary files\n- `profile_file_prefix` + `enable_profiling` — writes profiling JSON to arbitrary path\n- `register_custom_ops_library` — loads arbitrary shared libraries (method, not property)\n\n## Files in ONNX Runtime\n\n- `onnxruntime\u002Fpython\u002Fbackend\u002Fbackend.py` — `_ALLOWED_SESSION_OPTIONS`\n- `onnxruntime\u002Fpython\u002Fbackend\u002Fbackend_rep.py` — `_ALLOWED_RUN_OPTIONS`\n- Tests: `onnxruntime\u002Ftest\u002Fpython\u002Fonnxruntime_test_python_backend.py` — `TestBackendKwargsAllowlist`\n",{"name":5,"description":7},"main","4edd78a847b9d7755f32d6c99aa60cab2addd39b",".github\u002Fskills\u002Fpython-kwargs-setattr-security",4439,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fonnxruntime","https:\u002F\u002Fonnxruntime.ai","https:\u002F\u002Fgithub.com\u002Fmicrosoft","https:\u002F\u002Fopensource.microsoft.com","Open source projects and samples from Microsoft","2026-11-12 03:12:39",{"source":8,"skillName":5,"commands":55,"prompt":65,"zipAvailable":66},[56,59,62],{"tool":57,"command":58},"npx","npx skills add microsoft\u002Fonnxruntime --skill python-kwargs-setattr-security",{"tool":60,"command":61},"bunx","bunx skills add microsoft\u002Fonnxruntime --skill python-kwargs-setattr-security",{"tool":63,"command":64},"pnpm","pnpm dlx skills add microsoft\u002Fonnxruntime --skill python-kwargs-setattr-security","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fonnxruntime\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fpython-kwargs-setattr-security\u002FSKILL.md",true,[],[69,99,133,152,168,192],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":80,"publishedAt":39},"01M69AJ65WPPT5DS4JA8YWN37B","workspace-estimation-shared-header","Use when editing a boundary-safe shared header meant to be included by both in-tree and shared-provider\u002Fplugin-bridge code (e.g. include\u002Fonnxruntime\u002Fcore\u002Fframework\u002Fworkspace_requirement.h, or any future header supporting OrtKernelWorkspaceEstimateFunc \u002F DeclareWorkspaceRequirements per issue #29775's Phase-A workspace-estimation roadmap), or when a workspace-estimation math helper needs to be callable from a future plugin EP DLL. Covers a Node forward-declaration ODR trap and the math-helper vs. graph-parsing-wrapper reuse boundary discovered while implementing PR #29811 (MatMulNBits pilot).","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fonnxruntime\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fworkspace-estimation-shared-header\u002FSKILL.md",[75],{"categoryNo":76,"categoryName":77,"taxonomyType":78,"taxonomyTypeDesc":79},"01JBSEEDCAT000000000000031","产品经理","PROFESSION","适用职业",[81,82,83,84,85,86,37,87,88,89,90,91,92,93,94,95,96,97,98,22],"workspace estimation shared header","workspace","estimation","shared","safe","pr","framework","graph","parsing","node","math","bridge","roadmap","Wrapper","issue","tree","implementing","phase",{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":110,"publishedAt":39},"01M69AJ3F3NXDS7QP76KZ9EX5H","webgpu-local-testing","Build and run ONNX Runtime WebGPU provider tests on Linux WITHOUT a real GPU, using a software Vulkan adapter (Mesa lavapipe). Use when you need to exercise WebGPU EP kernels off-Mac — the Linux webgpu CI leg is build-only, so software Vulkan is how you actually run WebGPU correctness tests locally. SCOPE - lavapipe only validates host-side enforce\u002Fshape bugs and MatMul-free kernels; any graph containing MatMul (including the expanded-Attention node tests) crashes lavapipe and runs ONLY on macOS-arm64 Metal, which is the source of truth for those. Covers install (dnf on Azure Linux), the --use_webgpu build flag, the onnxruntime_provider_test target, VK_ICD_FILENAMES, and the lavapipe MatMul crash gotcha.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fonnxruntime\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fwebgpu-local-testing\u002FSKILL.md",[105],{"categoryNo":106,"categoryName":107,"taxonomyType":108,"taxonomyTypeDesc":109},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",[111,112,113,114,115,116,117,118,119,120,38,121,122,123,124,90,125,126,127,128,129,130,131,132,22],"testing","webgpu","webgpu local testing","local testing","local","macos","metal","vulkan","linux","test","run","ci","exercise","how","install","only","free","host","scope","you","vk","which",{"skillNo":134,"name":135,"nameZh":6,"description":136,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":137,"categories":138,"keywords":139,"publishedAt":39},"01M69AHZ0M0Q90TP0KYMZ10HEP","ort-transformers-gpu-pytest","Run the ONNX Runtime transformers Python tests (onnxruntime\u002Ftest\u002Fpython\u002Ftransformers) against a GPU wheel, and confirm real cuDNN\u002Fflash SDPA dispatch. Use when a transformers pytest fails with ModuleNotFoundError onnxruntime.capi, when torch's bundled CUDA\u002FcuDNN libs shadow the ORT-built ones (wrong-version dispatch or load errors), or when you must PROVE a test exercised the cuDNN SDPA decode tier instead of silently skipping\u002Ffalling back to MATH.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fonnxruntime\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fort-transformers-gpu-pytest\u002FSKILL.md",[],[140,141,142,143,20,120,38,121,144,91,33,145,29,146,147,130,148,149,150,151,22],"ort transformers gpu pytest","gpu","Transformers","pytest","flash","back","tests","SDPA","errors","load","prove","decode",{"skillNo":153,"name":154,"nameZh":6,"description":155,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":156,"categories":157,"keywords":159,"publishedAt":39},"01M69AHW3EFVHBHB2S7103YA21","ort-test","Run ONNX Runtime tests. Use this skill when asked to run tests, debug test failures, or find and execute specific test cases in ONNX Runtime.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fonnxruntime\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fort-test\u002FSKILL.md",[158],{"categoryNo":106,"categoryName":107,"taxonomyType":108,"taxonomyTypeDesc":109},[120,160,161,162,163,38,164,121,165,166,33,29,146,167,22],"ort test","run tests","debug","debug test","debug test failures","find","execute","test cases",{"skillNo":169,"name":170,"nameZh":6,"description":171,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":172,"categories":173,"keywords":174,"publishedAt":39},"01M69AHSKXBSERP5NGAJB5E6XD","ort-release-notes","Draft ONNX Runtime release notes using preset configurations for full ORT or scoped component releases. Use when generating highlights with PR links, compiling human contributor acknowledgments from compile_contributors.py output, and applying preset path filtering.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fonnxruntime\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fort-release-notes\u002FSKILL.md",[],[175,176,177,178,179,180,38,86,181,182,183,184,185,186,29,187,188,189,190,191,22],"notes","ort release notes","release notes","release","component","preset","compile","compiling","contributors","releases","human","full","links","path","for","scoped","contributor",{"skillNo":193,"name":194,"nameZh":6,"description":195,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":196,"categories":197,"keywords":201,"publishedAt":39},"01M69AHQAPER0CRAZ0FTX0G2FT","ort-lint","Lint and format ONNX Runtime code. Use this skill when asked to lint, format, or check code style for C++ or Python files in ONNX Runtime.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fonnxruntime\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fort-lint\u002FSKILL.md",[198],{"categoryNo":199,"categoryName":200,"taxonomyType":108,"taxonomyTypeDesc":109},"01JBSEEDCAT000000000000007","代码审查",[202,203,20,204,38,37,205,206,33,207,30,29,208,189,22],"ort lint","lint","code style","format","check","files","style"]