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

rust-i18n-support: Use-after-free when setting the locale #1855

Merged
merged 2 commits into from
Jan 23, 2024
Merged

rust-i18n-support: Use-after-free when setting the locale #1855

merged 2 commits into from
Jan 23, 2024

Conversation

Kijewski
Copy link
Contributor

Version 3.0.0 introduced an AtomicStr type, that is used to store the current locale. It stores the locale as a raw pointer to an Arc<String>. The locale can be read with AtomicStr::as_str(). AtomicStr::as_str() does not increment the usage counter of the Arc.

If the locale is changed in one thread, another thread can have a stale -- possibly already freed -- reference to the stored string.

@Shnatsel
Copy link
Member

Thank you for the report!

I would like to give the maintainers some time to publish a fix, so that the advisory is actionable once it goes live. But if the maintainer doesn't respond, we can merge as-is to at least notify users of the crate.

@Shnatsel Shnatsel added the Waiting-Maintainer Waiting-Maintainer label Jan 19, 2024
@Kijewski
Copy link
Contributor Author

A fix was released in https://github.com/longbridgeapp/rust-i18n/releases/tag/v3.0.1.

I changed the scope from rust-i18n to rust-i18n-support, because that's the actually affected crate, and someone could use rust_i18n_support::AtomicStr outside of rust_i18n.

@Kijewski Kijewski changed the title rust-i18n: Use-after-free when setting the locale rust-i18n-support: Use-after-free when setting the locale Jan 23, 2024
@tarcieri tarcieri merged commit b1db690 into rustsec:main Jan 23, 2024
1 check passed
@Kijewski Kijewski deleted the pr-rust-i18n branch January 23, 2024 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Waiting-Maintainer Waiting-Maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants