Rules
soc2-no-leak-user-data

SOC2 Don’t leak user data

Don’t log potentially sensitive customer data or we’ll lose our SOC2 certification.

Non-identifying user data such as internal IDs or other internal models related to a user are fine to log and expose.

Examples

Incorrect Examples

// Don't log potentially sensitive user data
console.log(user)
// Don't log potentially sensitive user data
log.info(user)
// Don't log sensitive user information like `email`
console.error('Invalid user', user.email)
// Don't log request bodies which may contain sensitive user data
log.info({ body: req.body })
// Don't expose request bodies which may contain sensitive user data
throw new Error('error', { body: req.body })

Correct Examples

// Logging non-identifying user data such as internal IDs is fine
console.log(user.id)
// Logging non-identifying user data such as internal IDs is fine
logger.warn(`Invalid user: ${user.id}`)
// Exposing non-identifying user data such as internal IDs is fine
throw new Error(`User error ${user.id}`)
// Logging internal resources related to a user is okay
console.log(user.posts)

Metadata

KeyValue
namesoc2-no-leak-user-data
levelerror
scopefile
fixablefalse
cacheabletrue
tags[ security ]
gritqlNumLinesContext2
gritqltrue