ICU-23359 Fix use-after-free race in TransliteratorAlias compoundFilter
Checklist
- [x] Required: Issue filed: ICU-23359
- [x] Required: The PR title must be prefixed with a JIRA Issue number. Example: "ICU-NNNNN Fix xyz"
- [x] Required: Each commit message must be prefixed with a JIRA Issue number. Example: "ICU-NNNNN Fix xyz"
- [ ] Issue accepted (done by Technical Committee after discussion)
- [x] Tests included, if applicable
- [ ] API docs and/or User Guide docs changed or added, if applicable
- [x] CLA signed
Summary
TransliteratorAlias stored a raw non-owning pointer to the TransliteratorEntry's compoundFilter. When the registry mutex is released between registry->get() and alias->create(), a concurrent Transliterator::unregister() call can delete the entry (and its compoundFilter) while the alias still holds a dangling pointer, causing a use-after-free.
The source comment at transreg.cpp lines 30-36 notes that BoundsChecker has reported dangling pointer errors with these entry objects, corroborating this race condition.
Changes
- Clone
compoundFilterin bothTransliteratorAliasconstructors instead of storing a raw alias pointer - Delete owned
compoundFilterin~TransliteratorAlias() - Update header comment and type from
const UnicodeSet*(alias) toUnicodeSet*(owned) - Add
TestTransliteratorAliasCompoundFilterRaceintsmthred.cppto exercise concurrentcreateInstance()+unregister()with a compound-filter transliterator
Test plan
- [x] Existing ICU transliterator tests pass
- [x] Concurrent
createInstance+unregisteron the same ID no longer triggers UAF (new test:TestTransliteratorAliasCompoundFilterRace)
@hirorogo Could you please sign the CLA -- otherwise we can't look at your changes -- and create a Jira ticket with the problem description?
Hooray! The files in the branch are the same across the force-push. 😃
~ Your Friendly Jira-GitHub PR Checker Bot
Hooray! The files in the branch are the same across the force-push. 😃
~ Your Friendly Jira-GitHub PR Checker Bot
Hooray! The files in the branch are the same across the force-push. 😃
~ Your Friendly Jira-GitHub PR Checker Bot
I've restored the PR template, added a unit test (TestTransliteratorAliasCompoundFilterRace), and the CLA is signed. Could you please create a Jira ticket for this issue? I'll update the PR title and commit message with the ticket ID once assigned. Thank you!
Hooray! The files in the branch are the same across the force-push. 😃
~ Your Friendly Jira-GitHub PR Checker Bot
@markusicu CLA is signed, and I've created the Jira ticket: ICU-23359. The PR title and commit message are updated with the ticket ID.
A unit test (TestTransliteratorAliasCompoundFilterRace) is included in tsmthred.cpp — it exercises concurrent createInstance() + unregister() with a compound-filter transliterator.
Could the Technical Committee please accept ICU-23359 when you get a chance? The jira-ticket CI check is currently failing because the ticket status is still "New".
Thank you!
Hooray! The files in the branch are the same across the force-push. 😃
~ Your Friendly Jira-GitHub PR Checker Bot
plz reviews @markusicu @aheninger @qdan8556-glitch