T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- scripts/export-credentials.sh:220
- Finding
- Unrestricted Admin Macaroon Is Exported to the Less-Trusted Agent Machine<![CDATA[ ## Vulnerability Details **File Location**: `scripts/export-credentials.sh:220-249` **Additional Locations**: `SKILL.md:127-136`, `SKILL.md:203-218`, `references/architecture.md:59-63` **Vulnerability Type**: Excessive credential privileges and violation of least privilege **Risk Level**: Critical ### Vulnerable Code ```bash # Copy admin macaroon. if [ -n "$RPCSERVER" ]; then # Remote mode: use the provided --macaroonpath as the bundle macaroon. if [ -z "$MACAROONPATH" ]; then echo "Error: --macaroonpath required for remote export (needed for bundle)." >&2 exit 1 fi cp "$MACAROONPATH" "$BUNDLE_DIR/admin.macaroon" elif [ -n "$CONTAINER" ]; then MACAROON="$LND_SIGNER_DIR/data/chain/bitcoin/$NETWORK/admin.macaroon" docker cp "$CONTAINER:$MACAROON" "$BUNDLE_DIR/admin.macaroon" 2>/dev/null if [ ! -f "$BUNDLE_DIR/admin.macaroon" ]; then echo "Error: Admin macaroon not found at $MACAROON in container '$CONTAINER'" >&2 exit 1 fi else MACAROON="$LND_SIGNER_DIR/data/chain/bitcoin/$NETWORK/admin.macaroon" if [ ! -f "$MACAROON" ]; then echo "Error: Admin macaroon not found at $MACAROON" >&2 exit 1 fi cp "$MACAROON" "$BUNDLE_DIR/admin.macaroon" fi echo " admin.macaroon copied." echo "" # Create portable base64-encoded tar.gz bundle. BUNDLE_ARCHIVE="$LNGET_SIGNER_DIR/credentials-bundle.tar.gz.b64" echo "Creating portable bundle..." tar -czf - -C "$BUNDLE_DIR" accounts.json tls.cert admin.macaroon | base64 > "$BUNDLE_ARCHIVE" ``` ### Technical Analysis The Skill's legitimate requirement is to authorize the watch-only node to invoke a limited set of remote-signing and key-derivation operations. Instead, the default workflow copies the signer's unrestricted `admin.macaroon` and transfers it to the agent machine. An LND admin macaroon authorizes substantially more RPC operations than the signing workflow requires. Transferring it across the signer trust boundary ther ...[truncated 1471 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Bake a dedicated signer macaroon during setup and export that credential instead of `admin.macaroon`. 2. Grant only the RPC permissions actually required by the watch-only node, such as the reviewed Signer and WalletKit methods documented by the project. 3. Make least-privilege macaroon generation the default and fail closed if it cannot be completed. 4. Require an explicit option such as `--allow-admin-macaroon` for exceptional development use, accompanied by a prominent warning and confirmation. 5. Name the exported file according to its actual role, such as `signer-only.macaroon`. 6. Rotate any admin macaroon that has already been transferred to an agent machine. 7. Add automated tests that inspect the baked macaroon permissions and reject administrative permissions not required by the remote-signing protocol. ]]>
