T05 · Unauthorized Access and Privilege Escalation
- Location
SKILL.md:30- Finding
Database-Wide Chat Access Through a PostgreSQL Superuser Account
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:30-35
Vulnerability Type: Excessive database privileges and missing access-control boundaries
Risk Level: Highmarkdown ## Database Connection - **Host**: 127.0.0.1, **Port**: 15432, **User**: postgres, **DB**: openclaw_audit - **psql**: `LC_ALL=C /opt/homebrew/Cellar/postgresql@18/18.2/bin/psql -h 127.0.0.1 -p 15432 -U postgres -d openclaw_audit` - **Important**: Must use PG 18 binary and `LC_ALL=C` prefixTechnical Analysis
The Skill instructs the agent to connect to the audit database using the PostgreSQL
postgresaccount. This account is conventionally a database superuser and is not restricted to the read-only message-search operations required by the Skill.The supplied query patterns allow database-wide searches and chat enumeration, but the Skill does not require requester authorization, chat ownership verification, row-level security, or filtering records to an authorized user. A
LIMITonly restricts the number of rows returned by one query; it does not provide an access-control boundary.The accessible schema contains private message bodies, phone numbers, sender identities, chat identifiers, session UUIDs, model information, and cost metadata. Consequently, compromise or misuse of this Skill can affect records beyond the conversation legitimately relevant to the requester.
Attack Path
- A user asks the agent to enumerate chats or retrieve messages associated with another person, group, date, or keyword.
- The agent follows the Skill and connects as the
postgresdatabase user. - The agent executes a broad query against
messages, without verifying whether the requester is authorized to access the selected chats. - The query returns private messages and identifying metadata from unrelated conversations.
- Because the connection uses a highly privileged account, an injected or mistakenly generated statement could potenti ...[truncated 519 chars]
- Remediation
View remediation
Remediation Suggestions
- Replace the
postgresaccount with a dedicated read-only role that can access only the required columns and rows. - Revoke
INSERT,UPDATE,DELETE,TRUNCATE, DDL, role-management, and database-administration privileges from the Skill account. - Enforce PostgreSQL row-level security based on the authenticated requester's authorized chat identifiers.
- Require explicit authorization checks before searching, quoting, or replying to messages from a chat.
- Remove or disable database-wide chat enumeration for ordinary users.
- Expose a narrowly scoped search API or stored procedure instead of arbitrary SQL access.
- Redact phone numbers, session UUIDs, message IDs, and other identifiers unless they are essential to the authorized request.
- Enable audit logging and rate limits for message searches and repeated pagination.
- Configure sessions with
default_transaction_read_only = onand a strict statement timeout as defense-in-depth controls.
- Replace the
