Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MONGOID-5810 Don't leak internal state via #as_document #5899

Merged
merged 3 commits into from
Nov 18, 2024

Conversation

jamis
Copy link
Contributor

@jamis jamis commented Nov 11, 2024

Under certain situations, and when legacy_attributes is true, the hash returned from #as_document can be the actual hash used internally to represent the model. Modifying this hash will modify the internal state of the model, which is unexpected and dangerous.

To fix this, the attributes must be deep-duplicated before being returned by #as_document, if legacy_attributes is true.

This does not affect 9.0-stable and later, because the legacy_attributes setting was removed when 9.0 was released.

(This ought to be backported to 8.0-stable, however.)

@jamis jamis merged commit c2f078f into mongodb:8.1-stable Nov 18, 2024
45 of 58 checks passed
jamis added a commit to jamis/mongoid that referenced this pull request Nov 18, 2024
jamis added a commit that referenced this pull request Dec 19, 2024
…backport to 8.0-stable) (#5903)

* make sure we don't leak internal state via as_document (#5899)

* start trying to fix the broken 8.0-stable test environment

* more test reconfiguring

* fiddling with configuration

* fix a couple more failing tests, maybe
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