Prompt
I'm building a permission-aware enterprise search layer for sensitive internal content. What should I avoid?
Latest observation
For a permission-aware enterprise search layer over sensitive internal content, the biggest things to avoid are the patterns that quietly turn “search” into a data-exposure system.
What to avoid
1. Indexing content without security trimming
Never build an index that ignores document-level or field-level permissions.
If the search backend can retrieve a result the user shouldn’t know exists, that’s already a leak.
Avoid:
- One shared index with no ACL metadata
- Relying on the UI to hide restricted results
- Post-filtering after returning full snippets or highlights
2. Leaking through snippets, highlights, or metadata
Even if the document body is hidden, titles, previews, highlighted terms, authors, path names, and timestamps can expose sensitive information.
Avoid exposing:
- Snippets from unauthorized documents
- Query-dependent highlights for restricted content
- File paths, project names, ticket IDs, customer names, or owner names that reveal confidential context
3. Using stale permissions
Search results must reflect current access, not yesterday’s access.
Avoid:
- Long-lived ACL caches without invalidation
- Eventually consistent permission sync for highly sensitive data
- Reindexing content separately from permission changes
4. Querying before authorization
Don’t let the search service do broad retrieval and then “decide later” in a way that could leak timing, ranking, or partial results.
Avoid:
- Returning counts for unauthorized corpora
- Rank differences that reveal existence of restricted content
- Side channels from empty-result behavior vs denied behavior
5. Overbroad group or inheritance logic
Permission resolution is where many systems fail.
Avoid:
- Flattening nested groups incorrectly
- Treating inherited access as universal access
- Ignoring deny rules, exceptions, or resource-specific overrides
- “Everyone in department X can see all of Y” shortcuts
6. Storing sensitive raw content in places with weaker controls
Indexes, caches, logs, analytics pipelines, and error traces often become the weakest link.
Avoid:
- Logging queries and result payloads verbatim
- Storing full document bodies in search indexes if not necessary
- Shipping indexed content to third-party observability tools
- Debug dumps with snippets or ACLs
7. Cross-tenant or cross-domain contamination
If you serve multiple business units, customers, or environments, isolate them strongly.
Avoid:
- Shared indexes without hard tenant partitioning
- Reusing embeddings or vector stores across tenants without access isolation
- Global autocomplete or query suggestion corpora
8. Relying on embeddings/vector search without permission filters
Semantic retrieval can surface highly sensitive text even when exact keyword search is constrained.
Avoid:
- Vector search that runs before ACL checks
- Embedding documents without a permission model
- Assuming “it’s just vectors” means it’s safe
9. Letting autocomplete, suggestions, and analytics leak data
Search UX features are often overlooked.
Avoid:
- Query suggestions built from all users’ searches
- Autocomplete over restricted document titles
- Popularity/ranking metrics that expose sensitive internal topics
- “Did you mean” based on hidden corpus terms
10. Weak auditability
If you can’t explain who saw what and why, you can’t defend the system.
Avoid:
- No access logs for search results
- No trace from query → candidate set → permission decision
- Inability to reconstruct permission state at query time
11. Client-side enforcement
Never trust the browser or frontend to enforce access control.
Avoid:
- Sending unauthorized result IDs to the client
- Hiding results in the UI while still exposing APIs
- Download links that are guessable or reusable without authorization
12. One-size-fits-all retention
Sensitive search artifacts should not live forever.
Avoid:
- Indefinite retention of query logs
- Storing historic search results with sensitive snippets
- Backups and replicas that are less protected than primary systems
Strong rule of thumb
If a user is not allowed to open a document, they also should not be able to infer:
- that it exists,
- what it is about,
- who owns it,
- how popular it is,
- or whether it matched their query.
Safer design habits
- Enforce authorization in the retrieval layer, not just the UI
- Trim by permissions before ranking/snippet generation
- Minimize stored sensitive text
- Separate tenants/business domains strongly
- Treat logs, caches, and suggestions as sensitive data stores
- Build for instant permission revocation
- Test for inference leaks, not just direct access leaks
If you want, I can also give you:
- a threat model checklist for permission-aware search, or
- a reference architecture for building it safely.