T09 · Insecure Skill Coding Practices
- Location
scripts/sw_api.py:89- Finding
Unconditional Closure of Unrelated SOLIDWORKS Documents
- Content
View full analysis
Vulnerability Details
File Location:
scripts/sw_api.py:89-93, invoked by all supplied build scripts immediately after connecting to SOLIDWORKS
Vulnerability Type: Unconfirmed destructive operation affecting unrelated application state
Risk Level: MediumComplete Code Snippet
python def close_all(sw): try: sw.CloseAllDocuments(True) except Exception: passRepresentative invocation:
python sw = connect() close_all(sw)The invocation occurs at:
scripts/build_assembly.py:25-26scripts/build_cup_shell.py:10-11scripts/build_drawing.py:12-13scripts/build_flange.py:10-11scripts/build_flower.py:25-26scripts/build_gear.py:98-99scripts/build_hook.py:16-17scripts/build_hook_loft.py:24-25scripts/build_mug.py:21-22scripts/build_spring.py:10-11
Technical Analysis
The connection helper can attach to an already-running SOLIDWORKS instance. Every supplied build script then calls
close_all(sw)unconditionally. The helper invokesCloseAllDocuments(True)without checking which documents were opened by the Skill, whether existing documents contain unsaved changes, or whether the user authorized closing unrelated work.The Skill documentation describes modeling and file-conversion operations, but the executable path expands a request to build one model into a bulk operation against all documents in the attached SOLIDWORKS session. There is no explicit opt-in flag, confirmation gate, dry-run mode, ownership tracking, or backup step. The broad exception handler also suppresses failures, reducing visibility into whether documents were partially closed.
This is a reachable destructive behavior rather than evidence of malicious intent.
Attack Path
- The user has one or more documents open in an existing SOLIDWORKS session, potentially with unsaved changes.
- The user invokes any supplied build script to create the script's advertised model.
connect()at ...[truncated 820 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove the unconditional
close_all(sw)calls from the build scripts. - Track documents created or opened by the current script and close only those documents by exact title or document identity.
- Before closing any pre-existing document, inspect its modified or unsaved state and request explicit user confirmation.
- If bulk closure is operationally necessary, require an explicit command-line opt-in such as
--close-all-documents; default to preserving existing documents. - Provide a dry-run or enumeration mode that lists affected documents before performing closure.
- Do not suppress all exceptions. Report closure failures and stop safely if document ownership or save state cannot be established.
- Consider launching a dedicated SOLIDWORKS instance for automation where supported, isolating the task from the user's interactive session.
- Remove the unconditional
