T09 · Insecure Skill Coding Practices
- Location
scripts/instagram.mjs:18- Finding
Write Operations Are Enabled by Default Despite a Read-Only Safety Claim
- Content
View full analysis
p.trim().toLowerCase()); ``` Permission derivation and write-command enforcement: ```javascript const hasRead = PERMISSIONS.includes('read'); const hasWrite = PERMISSIONS.includes('write'); // Commands that require write permission const WRITE_COMMANDS = [ 'send', 'start-chat', 'create-post', 'comment', 'react' ]; // Commands that are read-only const READ_COMMANDS = [ 'accounts', 'account', 'chats', 'chat', 'messages', 'profile', 'my-profile', 'relations', 'followers', 'posts', 'post', 'attendees', 'comments' ]; ``` ```javascript function checkPermission(cmd) { if (WRITE_COMMANDS.includes(cmd) && !hasWrite) { console.error(`Error: Command '${cmd}' requires write permission.`); console.error(`Current permissions: ${PERMISSIONS.join(', ')}`); console.error(`Set UNIPILE_PERMISSIONS=write or UNIPILE_PERMISSIONS=read,write to enable.`); process.exit(3); } if (READ_COMMANDS.includes(cmd) && !hasRead) { console.error(`Error: Command '${cmd}' requires read permission.`); console.error(`Current permissions: ${PERMISSIONS.join(', ')}`); console.error(`Set UNIPILE_PERMISSIONS=read to enable.`); process.exit(3); } } ``` Contradictory documentation: ```markdown ## 🛡️ Permission Modes By default, the skill operates in read-only mode for safety. **Read-only** (`UNIPILE_PERMISSIONS=read`): ``` ### Technical Analysis The implementation assigns `read,write` whenever `UNIPILE_PERMISSIONS` is absent. Consequently, `hasWrite` evaluates to `true`, and the local permission check permits all write commands, including sending direct messages, starting conversations, ...[truncated 1808 chars]- Remediation
View remediation
permission.trim().toLowerCase()); ``` 2. Reject unknown or empty permission values rather than silently accepting malformed configuration. 3. Require an explicit `write` setting before enabling any mutating command. 4. Add an interactive confirmation or a separate non-interactive confirmation flag for consequential operations such as sending DMs and creating posts. 5. Where supported by Unipile, use separately scoped or server-enforced read-only credentials rather than relying solely on a local environment variable. 6. Make the behavior consistent across `SKILL.md`, source comments, and CLI help. 7. Add automated tests asserting that every write command is rejected when `UNIPILE_PERMISSIONS` is absent or set to `read`. ]]>
