# Kuan Yin — Security

> Technical doc 32.16.1.12. Surfaces in `@kuanyin/sdk-api` (auth),
> `@kuanyin/performer-protection` (NCII), `@kuanyin/dharma-analytics`
> (`threat-detection`, `safety-protocols`).

## Authentication & authorization

- Seven auth methods (`api_key` … `mutual_tls`), each with a computed security
  level; MFA raises the level and is required for the strongest sessions.
- Sensitive scopes (`admin`, `write:users`, `delete`, `write:config`) require
  `securityLevel ≥ 0.8` and are withheld with a warning otherwise.
- GraphQL uses authorization directives + query-complexity limits; REST uses
  per-endpoint rate-limit rules.

## Abuse & threat detection (defensive)

All detectors score **upstream-extracted feature vectors** to surface harm for
human review — nothing generates harm or aids evasion:

- `threat-detection` — multi-turn grooming-stage detection (mandatory-review
  gating), sextortion immediate-escalation, radicalisation trajectory, illegal
  solicitation, off-platform correlation, AI red-teaming for policy gaps.
- `advanced-nlp` — dog-whistle, adversarial-text, unicode-abuse, and obfuscation
  detection so evasion attempts are caught.
- `deepfake-detection` — reliability-weighted detector fusion, biological-signal
  and temporal-consistency checks, C2PA verification, adversarial-robustness
  hardening that forces review when anti-forensic evasion is suspected.

## NCII & non-consensual media

`performer-protection/ncii-deepfake-protection.ts` integrates StopNCII.org and
PhotoDNA hashing, a performer face registry, automated takedown, evidence
preservation, and a hash-sharing network. The §32.19.3 `take-it-down-compliance`
module enforces the 48-hour NCII removal SLA, identical/near-duplicate re-upload
blocking, and a hash-chained legal audit trail.

## Irreversible actions

`requireHumanReviewForBan` forbids auto-applying bans, permanent suspensions,
and account terminations — a human must confirm first.
`validateEthicalCompliance` requires evidence and an appeal path before
approving high-severity actions.

## Secrets & integrity

- Webhook payloads are HMAC-signed; signing keys rotate per
  `09-configuration.md`.
- Audit access is recorded in a tamper-evident hash chain (`auditDataAccess` /
  `verifyAuditChain`) so any retroactive edit is detectable.
- Encryption at rest and in transit are validated against NIST-aligned policy
  (`assessEncryptionAtRest` / `assessEncryptionInTransit`).

## Reporting a vulnerability

Treat any bypass of protection, NCII removal, or human-review gating as a P1.
Follow `15-incident-response.md`; preserve evidence (do not delete the offending
content — hash and quarantine it).
