T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/reaction-processor.sh:3- Finding
Database Operations Execute Through an Administrative PostgreSQL Role
- Content
View full analysis
Vulnerability Details
File Location:
scripts/reaction-processor.sh, lines 3-5, 18, and 83
Vulnerability Type: Violation of least-privilege database access
Risk Level: HighVulnerable Code
sh DB_CONTAINER="supabase-db" DB_USER="postgres" DB_NAME="postgres"sh docker exec -i "$DB_CONTAINER" psql -U "$DB_USER" -d "$DB_NAME" <<SQLThe same administrative connection pattern is used by both supported commands.
Technical Analysis
The script enters the database container and invokes
psqlas the PostgreSQL administrative role. Its intended functionality only requires narrowly defined permissions to:- Read the applicable trigger rule and stale mission records.
- Insert rows into
public.openclaw_agent_events. - Insert rows into
public.openclaw_agent_reactions. - Update limited fire metadata in
public.openclaw_trigger_rules.
Using the
postgresrole grants substantially broader database authority than these operations require. The script therefore violates least privilege and turns modification or substitution of this file into a path for arbitrary administrative SQL execution.Exploitation requires the ability to modify the script or otherwise influence the SQL supplied to this administrative
psqlinvocation. It also requires permission to invoke Docker against the target container. No direct command-injection path from the script's documented command-line argument was identified.Attack Path
- An attacker gains the ability to modify or replace
scripts/reaction-processor.sh. - The attacker adds arbitrary SQL to either existing heredoc.
- A user or automated workflow invokes one of the documented commands.
- The script enters
supabase-dband runs the modified SQL aspostgres. - The injected SQL can access or alter database objects beyond the tables needed by this Skill.
Impact Assessment
Successful exploitation can provide admini ...[truncated 491 chars]
- Remediation
View remediation
Remediation Suggestions
- Create a dedicated database role for this Skill rather than using
postgres. - Grant only the required privileges:
SELECTon the specific trigger and mission fields.INSERTon the event and reaction tables.- A tightly constrained mechanism for updating only the applicable trigger metadata.
- Prefer a security-reviewed stored procedure that performs the complete operation and grant the Skill role only
EXECUTEon that procedure. - If a security-definer procedure is used, fix its
search_path, schema-qualify every object, validate all inputs, and revoke unnecessary public execution privileges. - Avoid Docker-mediated administrative database access. Use an authenticated connection with the dedicated role and protected credentials.
- Restrict write access to the script and verify its integrity before privileged automated execution.
- Create a dedicated database role for this Skill rather than using
