# Security Controls That Prevent Unauthorized Target Access Before auth.status=granted in reverse-skill

> Discover security controls that block unauthorized target access before auth.status=granted. Learn how reverse-skill implements a robust authorization gate with immutable rules and runtime checks.

- Repository: [ZhaoXu/reverse-skill](https://github.com/zhaoxuya520/reverse-skill)
- Tags: deep-dive
- Published: 2026-08-15

---

**The reverse-skill repository implements a defense-in-depth authorization gate that blocks all target interactions until the case scope explicitly records `auth.status=granted` alongside a defined `network_profile`, enforced through immutable rules, operational contracts, and runtime skill checks.**

The zhaoxuya520/reverse-skill package provides a structured framework for authorized security testing workflows. Understanding the **security controls that prevent unauthorized targets from being accessed before auth.status=granted** is critical for operators and AI agents to ensure compliant execution. The repository employs a multi-layered validation system spanning documentation, initialization scripts, and skill-level guards that collectively prohibit any action against targets without explicit authorization.

## Global Policy Controls in RULES.md

### Immutable Authorization Rules

The foundation of the security model rests in [`RULES.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md), which contains an absolute prohibition against acting on targets without proper authorization. According to the source code at [RULES.md (L20)](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md#L20), the rule states: "MUST NOT ACT against targets until auth.status=granted and network_profile set." This global rule is treated as immutable and must be obeyed before any skill file is executed.

### Redundant Rule Placement

To prevent accidental bypass during code reviews or merges, this same critical rule appears in three additional locations within the same file: [RULES.md (L150)](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md#L150), [L389](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md#L389), and [L396](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md#L396). This redundant placement ensures the authorization requirement cannot be overlooked regardless of which section an operator reads, guaranteeing the rule survives editing sessions intact.

## Operational Contract Enforcement

### Scope Contract Definition

The [`skills/ops/scope-contract.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/ops/scope-contract.md) file formalizes the mandatory fields required before any tool execution. At [scope-contract.md (L65)](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/ops/scope-contract.md#L65), the contract defines that `auth.status` and `network_profile` must be present and valid. Every skill performing an ACT operation must reference this contract, making it a programmatic gate that is checked manually or automatically before any tool launches.

### Automated Case Initialization

The `skills/scripts/case-init.ps1` script automates the creation of compliant case scopes. As documented in [AGENTS.md (L16)](https://github.com/zhaoxuya520/reverse-skill/blob/main/AGENTS.md#L16), this PowerShell script generates `work/<case>/scope.md` with the required authorization fields pre-populated. Downstream modules treat this script (or the resulting [`scope.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/scope.md)) as a prerequisite step, ensuring no skill executes without initialized scope documentation containing the proper security context.

## Runtime Skill Guards

### Entry Point Validation

Individual skill modules implement their own "NOW" steps that double-check the global authorization state. In [`skills/attack-chain/SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/attack-chain/SKILL.md) at [line 10](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/attack-chain/SKILL.md#L10), the skill aborts execution if `auth.status!=granted`. Similarly, [`skills/pentest-tools/SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/pentest-tools/SKILL.md) at [line 12](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/pentest-tools/SKILL.md#L12) contains an identical guard, creating a runtime enforcement layer that catches any attempts to bypass the documentation-level rules.

### Concrete Reference Implementation

The [`examples/ctf-demo/scope.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/examples/ctf-demo/scope.md) file ([L33-L49](https://github.com/zhaoxuya520/reverse-skill/blob/main/examples/ctf-demo/scope.md#L33)) demonstrates the complete workflow in practice. The case file transitions to "Change mode" only after `auth.status = granted` is explicitly recorded, serving as a concrete reference for developers showing exactly how the authorization gate manifests in real case files.

## AI Bootstrap Instructions

The [`README_AI.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/README_AI.md) file provides explicit instructions to automated agents regarding the authorization gate. At [line 42](https://github.com/zhaoxuya520/reverse-skill/blob/main/README_AI.md#L42), the bootstrap documentation commands: "Set `auth.status=granted` + `network_profile` before any target ACT." This ensures AI-driven workflows check the case-scope contract before executing any automated action, reinforcing the human-readable rules with machine-readable instructions that automated agents must follow.

## Implementation Examples

The following code snippets demonstrate how these controls materialize in practice:

**Case Initialization Pattern:**

```powershell

# skills/scripts/case-init.ps1

param([string]$Hint)
$scopePath = "work/$Hint/scope.md"
@"
auth.status = granted
network_profile = authorized_target_only
"@ | Out-File -Encoding ascii $scopePath
Write-Host "Case scope created with auth granted."

```

**Skill Entry Guard:**

```powershell

# skills/attack-chain/SKILL.md (excerpt)

$scope = Get-Content "work/$case/scope.md"
if ($scope -notmatch "auth\.status\s*=\s*granted") {
    Write-Error "Authorization not granted – aborting."
    exit 1
}

# continue with attack chain...

```

**Python Validation Check:**

```python

# example in a Python-based skill

import pathlib, sys
scope_file = pathlib.Path("work") / case / "scope.md"
if "auth.status = granted" not in scope_file.read_text():
    sys.exit("ERROR: auth not granted – stop execution")

```

## Summary

- **Global Policy Layer**: Immutable rules in [`RULES.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md#L20), L150, L389, L396) prohibit any ACT without `auth.status=granted` and `network_profile`.
- **Contract Enforcement**: [`skills/ops/scope-contract.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/ops/scope-contract.md#L65) defines mandatory fields, while `skills/scripts/case-init.ps1` programmatically initializes compliant scopes as referenced in [`AGENTS.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/AGENTS.md#L16).
- **Runtime Validation**: Individual skills like [`skills/attack-chain/SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/attack-chain/SKILL.md#L10) and [`skills/pentest-tools/SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/pentest-tools/SKILL.md#L12) implement abort gates that verify authorization before execution.
- **AI Agent Alignment**: [`README_AI.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/README_AI.md#L42) ensures automated workflows respect the authorization gate before processing target actions, and [`examples/ctf-demo/scope.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/examples/ctf-demo/scope.md#L33-L49) provides a reference implementation.

## Frequently Asked Questions

### What happens if a skill tries to execute without auth.status=granted?

The skill aborts immediately. According to the source code in [`skills/attack-chain/SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/attack-chain/SKILL.md) at line 10, if `auth.status` is not `granted`, the script outputs an error message and exits with status code 1 before any target interaction occurs, preventing unauthorized access attempts.

### Where is the authorization requirement defined for AI agents?

The requirement is defined in [`README_AI.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/README_AI.md) at line 42, which explicitly instructs AI agents to set `auth.status=granted` and `network_profile` before any target ACT. This ensures automated workflows comply with the security policy before executing any skill commands.

### How does the repository prevent the authorization rule from being accidentally removed?

The rule appears in four separate locations within [`RULES.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md#L20), L150, L389, L396). This redundant placement ensures the authorization requirement survives code reviews and merge conflicts, as multiple sections would need simultaneous modification to remove the protection completely.

### Can the case initialization script create scopes with unauthorized status?

No. The `skills/scripts/case-init.ps1` script creates [`scope.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/scope.md) files with `auth.status` explicitly set to compliant values. As referenced in [`AGENTS.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/AGENTS.md) at line 16, this script serves as the trusted mechanism for establishing case scopes, preventing manual errors that might otherwise skip authorization or create invalid security contexts.