T09 · Insecure Skill Coding Practices
- Location
scripts/x-search.sh:36- Finding
User-Controlled JavaScript Injection in an Authenticated Browser Context
- Content
View full analysis
- Remediation
View remediation
&2; exit 1 ;; esac case "$MIN_LIKES" in ''|*[!0-9]*) echo "Invalid minLikes" >&2; exit 1 ;; esac case "$SCROLL_TIMES" in ''|*[!0-9]*) echo "Invalid scrollTimes" >&2; exit 1 ;; esac ``` 4. **Enforce reasonable bounds** to prevent excessive browser activity or resource consumption, such as: - `MAX_RESULTS`: 1–100 - `MIN_LIKES`: 0–1,000,000,000 - `SCROLL_TIMES`: 0–20 5. **Prefer structured browser-evaluation arguments.** If `bb-browser` supports passing JSON arguments separately from source code, use that facility. The evaluated program should retrieve values from the structured argument object rather than from generated source. 6. **Add security regression tests** covering topics and arguments containing: - Single and double quotes - Backslashes - Newlines and Unicode line separators - Semicolons and parentheses - Template-literal characters - JavaScript comments - Non-numeric values and values outside permitted bounds 7. **Use proper URL encoding** for the search topic rather than replacing only spaces. A standard percent-encoder prevents the topic from changing query parameters or URL structure. ]]>
