T09 · Insecure Skill Coding Practices
- Location
references/code-examples/bria_client.sh:14- Finding
Bria API Credential Disclosure Through Unvalidated Request Destinations
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This Bria image API skill is purpose-aligned, but it needs review because it broadly routes image work to a third-party service and handles persistent API credentials in ways that could leak them.
Install only if you are comfortable sending prompts and images to Bria.ai and storing Bria credentials on this machine. Use it on a single-user trusted environment, protect or remove ~/.bria/credentials when not needed, avoid sensitive personal or proprietary images unless approved, and review the shell helper before using any non-default API base or async status URL behavior.
references/code-examples/bria_client.sh:14Bria API Credential Disclosure Through Unvalidated Request Destinations
SKILL.md:107OAuth and API Credentials Are Stored Without Explicit Restrictive Permissions
references/code-examples/bria_client.sh:36Predictable Shared Temporary Files Enable Symlink Attacks and Image Disclosure
The code is clearly related to Bria image API usage, so the overall domain matches the description. However, the description claims a fuller skill with OAuth device-flow authentication, credential caching behavior, and a wide catalog of image-manipulation capabilities. This code chunk only implements a generic authenticated API caller: it reads an existing API token from ~/.bria/credentials if present, constructs request payloads, sends POST requests, and polls async jobs. It does not implement OAuth device flow, does not itself cache credentials, and does not demonstrate the many specific operations beyond being usable with arbitrary endpoints. Because key declared functionality is not actually present in the supplied code chunk, the description overstates what this code does.
The skill directly accesses and processes highly sensitive credentials including access tokens, refresh tokens, and API keys. Because these secrets are read from and written to predictable filesystem locations, any over-privileged agent action, logging mistake, or local compromise could expose reusable credentials for unauthorized API use.
## Setup — Authentication
Before making any API call, you need a valid Bria access token.
### Step 1: Check for existing credentials
The skill embeds shell-based authentication and API invocation guidance but does not declare any explicit tool scope or allowed-tools boundary. That makes its operational privileges ambiguous and increases the risk that an agent could invoke shell/network actions more broadly than intended when the skill is selected.
The description explicitly advertises credential caching in ~/.bria/credentials, indicating persistent session material beyond the immediate task. Persistent authentication increases the blast radius of a local compromise and may cause future agent runs to inherit access without renewed user awareness or consent.
---
name: bria-ai
description: AI image generation, editing, and background removal API via Bria.ai — authenticates via OAuth device flow and caches credentials in ~/.bria/credentials, then calls 20+ endpoints to remove backgrounds for transparent PNGs and cutouts, generate images from text prompts, and edit photos with natural language instructions. Also create product photography and lifestyle shots, replace or blur backgrounds, upscale resolution, restyle, and batch-generate visual assets. Use this skill whenever the user wants to remove a background, create transparent PNGs, generate, edit, modify, or transform any image — including hero images, banners, social media visuals, product photos, illustrations, icons, thumbnails, ad creatives, or marketing materials. Also triggers on cutout, inpainting, outpainting, object removal or addition, photo restoration, style transfer, image enhancement, relight, reseason, sketch-to-photo, or any visual content creation. Commercially safe, royalty-free.
license: MIT
homepage: https://bria.ai
metadata:
The skill instructs storage of access, refresh, and API tokens in ~/.bria/credentials without clearly warning the user that long-lived credentials will be written to disk. Local credential persistence raises theft and misuse risk on shared or compromised systems, especially for refresh tokens that can mint new access tokens.
The activation guidance is extremely broad, effectively claiming almost any image-related request. Over-broad triggering can cause the agent to unnecessarily route user content, files, or prompts to an external third-party API, increasing privacy, consent, and data-handling risk.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
2a. Request a device code:
DEVICE_RESPONSE=$(curl -s -X POST "https://engine.prod.bria-api.com/v2/auth/device/authorize" \
-H "Content-Type: application/json")
echo "$DEVICE_RESPONSE"
This code persists both access and refresh tokens to ~/.bria/credentials, creating durable authentication state on disk. Refresh tokens are particularly sensitive because they can re-establish access after access-token expiry, making theft materially more damaging than transient session handling.
if [ -n "$ACCESS_TOKEN" ]; then
BRIA_ACCESS_TOKEN="$ACCESS_TOKEN"
REFRESH_TOKEN=$(printf '%s' "$TOKEN_RESPONSE" | sed -n 's/.*"refresh_token" *: *"\([^"]*\)".*/\1/p')
mkdir -p ~/.bria
printf 'access_token=%s\nrefresh_token=%s\n' "$BRIA_ACCESS_TOKEN" "$REFRESH_TOKEN" > "$HOME/.bria/credentials"
echo "AUTHENTICATED"
break
The token introspection request transmits the bearer access token to a remote service and then derives an API token from the response. While expected for this integration, it is still sensitive credential transmission; if triggered without clear consent or proper containment, it increases account compromise risk and expands exposure of secrets to external systems.
Introspect the bearer token to check billing status and obtain the real API key for Bria API calls:
INTROSPECT=$(curl -s -X POST "https://engine.prod.bria-api.com/v2/auth/token/introspect" \
-d "token=$BRIA_ACCESS_TOKEN")
BILLING_STATUS=$(printf '%s' "$INTROSPECT" | sed -n 's/.*"billing_status" *: *"\([^"]*\)".*/\1/p')
if [ "$BILLING_STATUS" = "blocked" ]; then
This reference instructs clients to send API tokens, image URLs/base64 image content, and free-form prompts to a third-party service but provides no privacy, retention, or data-handling warning. In an image-processing skill, users may submit sensitive photos or proprietary creative assets, so the omission can lead to uninformed disclosure of personal or confidential data to an external processor.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
# --- API call ---
result="/tmp/bria_result_$$.json"
http_code=$(curl -s -o "$result" -w '%{http_code}' -X POST \
"${BRIA_API_BASE}${endpoint}" \
-H "api_token: $BRIA_API_KEY" \
-H "Content-Type: application/json" \
The script automatically reads BRIA_API_KEY from ~/.bria/credentials and then uses it in outbound HTTP requests. While the header comment mentions auto-loading, there is no runtime notice, prompt, or other user-facing disclosure at the point of use for this sensitive credential access and transmission.
No suspicious patterns detected.