# Search And Pagination Scoping

> Verify search indexes, pagination cursors and sort operations never widen results past the caller's own scope. Use when the API offers search, filtering, sorting or cursor-based pagination over shared data sets

- Skill: `wsh7ash/search-and-pagination-scoping` (Agent Skill)
- Install (CLI): `npx get-skill add wsh7ash/search-and-pagination-scoping`
- Raw SKILL.md: https://api.skillmd.com/api/skills/wsh7ash/search-and-pagination-scoping/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- Author: Wsh7Ash (https://skillmd.com/u/wsh7ash)
- Updated: 2026-11-22
- Page: https://skillmd.com/skills/wsh7ash/search-and-pagination-scoping

---


# Search and Pagination Scoping

> Verify search indexes, pagination cursors and sort operations never widen results past the caller's own scope

**Use when:** the API offers search, filtering, sorting or cursor-based pagination over shared data sets

**Avoid when:** results are a fixed single object with no list or query surface to review

## Procedure

1. Populate both test accounts with distinctive labeled records so leakage is visible in any result set.
2. Run broad searches as each account, including wildcards and empty filters, and diff the result identifiers.
3. Walk pagination to its end for both accounts, checking that page boundaries never expose another scope's records.
4. Test sort and filter parameters, since query builders sometimes apply scope before filtering and sort after.
5. Check whether cursors encode scope, and whether substituting another account's cursor returns their page.
6. Record which layer applies the scope: index query, application filter or post-processing.

## Signals

- A wildcard search returns another test account's labeled records.
- A cursor from one account produces results from the other when replayed.
- Sorting by a field changes which records appear, suggesting scope is applied after ordering.
- Deep pages contain records that the first pages correctly excluded.

## Patterns

**1. Search diff**

```text
query=* as alice -> 38 hits, as bob -> 55 hits
overlap contains BOB-* rows in alice's results -> finding
```

**2. Cursor swap**

```text
cursor issued for alice replayed as bob -> returns alice's next page -> scope not encoded
```

**3. Result row**

```text
endpoint=/api/search scope=applied-at=index leaked=0 cursor=bound-to-session
```

## Pitfalls

- Testing only the first page, where filters are strongest and pagination is where they break.
- Using identical data for both accounts, making leakage invisible even if it occurs.
- Ignoring asynchronous index updates, where a record removed from one scope lingers in the index.

## Done when

- Wildcard search, full pagination traversal and cursor substitution have been tested for both accounts.
- The layer applying scope is identified and any leak is attributed to a specific query or step.

## References

- [OWASP API Security Top 10](https://owasp.org/www-project-api-security/)
- [OWASP Web Security Testing Guide](https://owasp.org/www-project-web-security-testing-guide/)

