Summary
OpenClaw embeds a long-lived shared gateway credential directly inside pairing setup codes generated by the /pair endpoint and openclaw qr command.
If setup codes are leaked through chat history, logs, or screenshots, an attacker can recover and reuse the embedded credential outside the intended one-time pairing flow to gain unauthorized access.
Affected context
This vulnerability affects OpenClaw environments that rely on the /pair endpoint or openclaw qr command to provision devices or clients using setup codes.
The issue is relevant when:
- Setup codes are treated as transient, one-time use tokens in workflows
- Setup codes are transmitted or stored in relatively low-trust channels (e.g., chat, ticketing, screenshots, logs)
- The embedded gateway credential is long-lived and shared across sessions, devices, or users
In such scenarios, exposure of a historical setup code can implicitly expose the underlying gateway credential.
Exploit preconditions
- Attack surface: Any channel or system where setup codes may be stored, forwarded, or displayed (messaging apps, ticket systems, log aggregators, screenshots).
- Required access: Ability to obtain a previously generated setup code (e.g., from chat history, support tickets, screenshots, terminal logs, or monitoring/logging systems).
- Trigger point: Using tools or documented formats to extract the embedded shared gateway credential from the setup code, then reusing it to connect to the gateway.
- Why exploitation is possible: The setup code contains a long-lived gateway credential rather than a strictly scoped, short-lived, one-time token; there is no robust binding between the code and a single pairing event or device, enabling replay and credential reuse.
Why this happens
The core issue is treating a high-value, long-lived shared gateway credential as if it were a transient setup artifact and embedding it directly into pairing setup codes.
This design conflates user-facing pairing tokens—often expected to be short-lived, single-use, and minimally sensitive—with stable authentication secrets that should be tightly protected and never exposed through user workflows.
This maps to CWE-522: Inadequate Protection of Credentials, where sensitive authentication material is stored or transmitted in a context that does not provide appropriate confidentiality or lifecycle controls, allowing recovery and unauthorized reuse by attackers.
Potential impact
- Unauthorized gateway access using recovered shared credentials
- Persistent unauthorized connectivity, as long as the embedded credential remains valid
- Impersonation of legitimate devices or clients during or after the pairing process
- Lateral movement to other systems that trust the gateway or its authenticated clients
- Data exfiltration, tampering, or misuse of gateway-managed resources
General mitigation guidance
Effective mitigation focuses on separating pairing tokens from durable credentials and reducing the sensitivity and lifetime of data embedded in user-facing codes.
Common defensive patterns include:
- Using ephemeral, one-time-use pairing tokens that cannot be reused after initial completion, and do not directly embed long-lived credentials.
- Deriving device- or session-specific credentials only on the server side after validating the pairing token, instead of shipping stable secrets inside the token.
- Applying strict scoping and expiration to any secrets involved in pairing flows, ensuring minimally sufficient privileges and short lifetimes.
- Avoiding shared gateway credentials across devices; instead, issue per-device or per-client credentials that can be individually revoked.
- Minimizing exposure of setup codes by design (e.g., reducing their presence in logs, masking them in UIs, and limiting where they are printed or displayed).
- Enforcing least privilege for any account or token used in pairing so that compromise yields minimal access.
How teams detect issues like this
Detection approaches typically rely on both design review and code-level analysis:
- Architectural review of authentication and pairing flows to confirm that user-facing tokens never contain long-lived or shared credentials.
- Static analysis or pattern-based code scanning to locate instances where:
- Gateway or service credentials are serialized directly into user-visible tokens or QR payloads.
- High-privilege secrets are passed into
/pairendpoint handlers or QR generation paths. - Code review checklists that include explicit questions about token structure, embedded secrets, and token lifetimes for pairing or provisioning features.
- Configuration and logging policies that flag or redact sensitive fields from logs and diagnostics, reducing the likelihood of sensitive credential exposure via monitoring infrastructure.
- Optional use of automated secrets-detection tools to scan token formats and repositories for embedded keys or credentials.

