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 make sure we don't leak internal state via as_document (backport to 8.0-stable) #5903

Open
wants to merge 1 commit into
base: 8.0-stable
Choose a base branch
from

Conversation

jamis
Copy link
Contributor

@jamis jamis commented Nov 18, 2024

(Backport from 8.1-stable to 8.0-stable.)

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.

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.

1 participant