# Privilege Change Session Hygiene

> Verify role, tenant and scope changes invalidate or reissue sessions, so stale credentials never outlive the privilege they once expressed. Use when administrators demote, suspend or change accounts' roles and the system promises control over materialized privileges

- Skill: `wsh7ash/privilege-change-session-hygiene` (Agent Skill)
- Install (CLI): `npx get-skill add wsh7ash/privilege-change-session-hygiene`
- Raw SKILL.md: https://api.skillmd.com/api/skills/wsh7ash/privilege-change-session-hygiene/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: Wsh7Ash (https://skillmd.com/u/wsh7ash)
- Updated: 2026-11-22
- Page: https://skillmd.com/skills/wsh7ash/privilege-change-session-hygiene

---


# Privilege Change Session Hygiene

> Verify role, tenant and scope changes invalidate or reissue sessions, so stale credentials never outlive the privilege they once expressed

**Use when:** administrators demote, suspend or change accounts' roles and the system promises control over materialized privileges

**Avoid when:** no privilege changes exist beyond initial account creation and rotation, in which case the change surface is empty

## Procedure

1. Create or select test identities whose roles you control and capture full sessions before any change.
2. Record the pre-change session material: cookie, bearer token, refresh chain and any derived view of the identity.
3. Apply the change, then call a representative operation set with both old and new session material.
4. Include read and write operations from the old role scope so success contradicts the admin's intent briefly and provably.
5. Watch caches, webhook registrations and background jobs, which may retain the pre-change authorization state.
6. Repeat for each change type the product supports, recording which session material survives each.

## Signals

- After a demotion, the old session performs an operation the new role could never reach.
- A suspended account continues producing responses that should have been impossible given its suspension state.
- Refresh rotation accepts a token issued before the privilege change and mint new credentials with the old role.
- Caches keyed purely by identity honor the change less strictly than the session examined directly.

## Patterns

**1. Change replay**

```text
status: member -> suspended  -> old session, next call: 200 -> session kept on change
```

**2. Refresh chain**

```text
refresh token from t0 still valid after demotion -> old-role inheritance via refresh
```

**3. Result row**

```text
change=demote session_state=live cache_state=stale refreshed_role=member-window 3m
```

## Pitfalls

- Testing the change only on the operation a UI calls, while a very similar operation lacks invalidation.
- Concluding expiry is a sufficient fix, since a session that expires tomorrow may still honor the new role today.
- Forgetting cache and background layers where session and request-time authorization drift apart.

## Done when

- Every role or status change type has been tested per session material with an exemplar operation before and after.
- Whether invalidation propagates to caches, refresh tokens, webhooks and background jobs is recorded per change type.

## References

- [OWASP - session management cheat sheet](https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html)
- [OWASP API Security Top 10](https://owasp.org/www-project-api-security/)

