gstack icon indicating copy to clipboard operation
gstack copied to clipboard

one-way-doors: revoke/reset credential patterns miss nouns rotate has — 'reset my secret' leaks through as two-way

Open jbetala7 opened this issue 5 months ago • 2 comments

Observed problem

scripts/one-way-doors.ts is the secondary keyword safety net for AskUserQuestion calls that fire without a registry id. Its three credential patterns are meant to be parallel across revoke/reset/rotate (the inline comment says they "allow filler words between verb and noun", and the test header for #1839 states "the credential-rotation patterns must be parallel across revoke/reset/rotate").

They are not. The noun alternations differ:

/\brevoke\s+[\w\s]*\b(api key|token|credential|access key|password)\b/i,        // missing: secret
/\breset\s+[\w\s]*\b(api key|token|password|credential)\b/i,                     // missing: secret, access key
/\brotate\s+[\w\s]*\b(api key|token|secret|credential|access key|password)\b/i, // complete

So a destructive credential operation phrased with the "wrong" verb/noun pair classifies as two-way (auto-decidable) instead of one-way (always ask). This is a false-negative in a safety net — the exact failure class #1839 fixed for rotate ... password.

Current behavior on upstream main (c7ae6320, v1.58.1.0)

$ bun -e 'import {classifyQuestion} from "./scripts/one-way-doors.ts"; ...'
two-way   revoke my secret      <- should be one-way
two-way   reset my secret       <- should be one-way
two-way   reset my access key   <- should be one-way
ONE-WAY   rotate my secret

Expected behavior

revoke/reset/rotate should share an identical credential noun list, so every <verb> my <noun> combination across {api key, token, secret, credential, access key, password} classifies as one-way.

Duplicate searches performed

  • open PRs and issues touching one-way-doors / "one-way door" — none cover this (only #1839/#1911 fixed rotate ... password, which is already on main)
  • searched open PRs for "revoke reset rotate" and the credential-noun subsystem — no collision
  • confirmed the existing test/one-way-doors.test.ts only checks the non-password nouns against rotate, never against revoke/reset

Candidate fix shape

Unify the noun alternation across all three verbs (add secret to revoke; add secret and access key to reset), and extend the regression test to assert every verb × noun pair is one-way.

jbetala7 avatar Jun 16 '26 09:06 jbetala7

This is a safety classification contract issue.

Credential verbs should probably be treated as one-way-door candidates even when the exact noun/verb pattern changes.

The unsafe class is broader than the current phrase list:

reset secret
rotate key
revoke token
delete credential
invalidate session
regenerate API key
remove webhook secret

A standard AISP-style contract could make the classification explicit:

[
  {
    "role": "system",
    "content": {
      "protocol": "AISP V1.0.0",
      "axiom_0": "Human_Sovereignty_and_Wellbeing",
      "id": "gstack_credential_one_way_door_contract_aisp",
      "name": "gstack Credential One-Way Door Contract",
      "version": "1.0.0",
      "license": "MIT",
      "summary": "Machine-checkable contract for classifying credential reset/rotate/revoke/delete actions as one-way-door operations.",
      "flow_format": "mermaid",
      "loading_mode": "node",
      "tools": [],
      "params": {
        "user_request": "string"
      },
      "system_prompt": ""
    }
  },
  {
    "role": "user",
    "content": {
      "instruction": "STRICTLY OBEY aisp_contract; its non_negotiable rules are inviolable; then RUN aisop.main",
      "user_input": "{user_input}",
      "aisp_contract": {
        "profile": "aisp.skill.v1",
        "invocation": {
          "mode": "safety_classification",
          "when_to_use": [
            "before classifying a user request as two-way or one-way",
            "when request involves secrets, tokens, keys, credentials, sessions, or auth artifacts"
          ],
          "when_not_to_use": [
            "pure read-only documentation about credential concepts",
            "mock examples with no action requested"
          ]
        },
        "non_negotiable": [
          {
            "rule": "Credential reset, revoke, rotate, delete, invalidate, and regenerate actions must be treated as one-way-door candidates.",
            "enforced_by": "classify.step2:sys.assert"
          },
          {
            "rule": "Do not downgrade credential mutation to two-way solely because noun phrasing differs.",
            "enforced_by": "classify.step3:sys.assert"
          }
        ],
        "discovery": {
          "category": "safety_classification",
          "tags": ["gstack", "one-way-door", "credentials", "secrets", "safety", "aisp"]
        },
        "risk_level": "high",
        "resources": []
      },
      "aisop": {
        "main": "graph TD\n    parse[Parse user request] --> detect[Detect credential objects]\n    detect --> classify[Classify action reversibility]\n    classify --> gate[Require confirmation if one-way]\n    gate --> end_node((End))"
      },
      "functions": {
        "parse": {
          "step1": "Parse user_request for action verbs and target objects.",
          "output_mapping": "request_terms"
        },
        "detect": {
          "step1": "Detect credential-like objects: secret, token, key, API key, password, session, credential, webhook secret.",
          "output_mapping": "credential_objects"
        },
        "classify": {
          "step1": "Classify action verbs: reset, rotate, revoke, delete, invalidate, regenerate, remove, destroy.",
          "step2": "sys.assert('credential mutation verbs classified as one-way-door candidates', 'Credential mutation must be treated as one-way-door candidate')",
          "step3": "sys.assert('noun variation does not bypass one-way classification', 'Credential noun variation must not downgrade risk')",
          "output_mapping": "reversibility_classification"
        },
        "gate": {
          "step1": "If one-way-door, require explicit confirmation or safety review.",
          "output_mapping": "safety_gate_decision"
        },
        "end_node": {
          "step1": "Return safety_gate_decision."
        }
      }
    }
  }
]

Practical fix:

1. Expand credential noun set.
2. Expand destructive credential verb set.
3. Match verb-object patterns, not only exact phrases.
4. Add regression tests:
   - reset my secret
   - rotate API key
   - revoke token
   - invalidate session
   - regenerate webhook secret

optimization2026 avatar Jun 30 '26 06:06 optimization2026

@16francej Please close this issue as resolved. Current main checks credential nouns together with revoke, rotate, and reset verbs, so phrases such as “reset my secret” are treated as dangerous one-way actions.

time-attack avatar Jul 15 '26 10:07 time-attack