Skip to content

Marking virtual attributes in Rails 5.1 may be exposing decrypted data #353

@stevenjackson

Description

@stevenjackson

When upgrading an application from Rails 5.0.7.2 to 5.1.7, I noticed that decrypted fields that used to be filtered out of our JSON responses are now included.

I believe this was caused by #263, if I comment out this line, the secrets stay secret.

attribute attr if ::ActiveRecord::VERSION::STRING >= "5.1.0"

My theory is that this is enabled because the field is now in attributes, which is enumerated when ActiveRecord creates a serializable_hash of a model.

https://github.com/rails/rails/blob/66cabeda2c46c582d19738e1318be8d59584cc5b/activemodel/lib/active_model/serialization.rb#L126

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions