Fail fast(er) for IDNA to_ascii() when given domain is too long
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 406
- PR merge metrics
- No merged PRs in 30d
Description
Currently IDNA to_ascii() conversion follows what's specified in https://www.unicode.org/reports/tr46/#ToASCII . However, this takes a really long time (up to 600 ms on my tests depending on the domain) to first convert and then validate length of too long domain names. Is there a reason not to bail out fast if domain name (in any coding) is over 253 Rust chars?
See code below:
For example my fuzzing found a domain name which is 221115 bytes long and it takes 551 ms to run to_ascii() on my machine. 539 ms is spent in idna::uts46::processing(), where 173 ms in idna::uts46::validate() and 157 ms in allocating strings. After all that tedious processing and validation is done, lengths are checked and all the effort is lost because lengths are obviously too long.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in idna/src/uts46.rs at the processing and validation code around lines 423-464. Reproduce the reported case with a very long domain passed to to_ascii(), then verify that length rejection happens earlier, preserves the specified behavior, and avoids the reported processing and allocation cost.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100