Skip to content

Don't show secrets for SignedGlobalID#inspect#160

Merged
rafaelfranca merged 1 commit intorails:mainfrom
p8:security/gid-inspect
Jun 30, 2023
Merged

Don't show secrets for SignedGlobalID#inspect#160
rafaelfranca merged 1 commit intorails:mainfrom
p8:security/gid-inspect

Conversation

@p8
Copy link
Copy Markdown
Member

@p8 p8 commented Jun 20, 2023

If anyone calls to_sgid on a model in the console it will show the secret of the encryptor.

By overriding the inspect method to only show the class name we can avoid accidentally outputting sensitive information.

Before:

SignedGlobalID.create(Person.new(5)).inspect
"#<SignedGlobalID:0x0000000104888038 ... @secret=\"muchSECRETsoHIDDEN\ ... >"

After:

SignedGlobalID.create(Person.new(5)).inspect
"#<SignedGlobalID:0x0000000104888038>"

If anyone calls `to_sgid` on a model in the console it will
show the secret of the encryptor.

By overriding the `inspect` method to only show the class name we can
avoid accidentally outputting sensitive information.

Before:

```ruby
SignedGlobalID.create(Person.new(5)).inspect
"#<SignedGlobalID:0x0000000104888038 ... @secret=\"muchSECRETsoHIDDEN\ ... >"
```

After:

```ruby
SignedGlobalID.create(Person.new(5)).inspect
"#<SignedGlobalID:0x0000000104888038>"
```
@rafaelfranca rafaelfranca merged commit 86ddaae into rails:main Jun 30, 2023
@p8 p8 deleted the security/gid-inspect branch July 1, 2023 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants