Skip to content

Hardcoded ActiveRecord Encryption Key

Description

The code contains a hardcoded ActiveRecord encryption key, which is a security risk as it can be accessed by unauthorized users.

Examples

Insecure Code

ruby
config.active_record.encryption.primary_key = "my_hardcoded_key"

Secure Code

ruby
config.active_record.encryption.primary_key = ENV['ENCRYPTION_KEY']

Remediation

Store the encryption key securely, such as in an environment variable or a secure secrets management system.

Rule Details

FieldValue
IDCODE-0763
CategorySecrets
SeverityCRITICAL
CWECWE-798
ConfidenceHIGH
ImpactHIGH
LikelihoodHIGH
ExploitabilityEASY
Tagshardcoded, encryption, activerecord
OWASPN/A

References