This thought/question was inspired/triggered by CRIME - How to beat the BEAST successor?
It was posted as a comment but obviously it should have been posted as a question, so here it is again:
The question is, suppose attacker can get into a man-in-the-middle situation between victim PC and security web server. Victim's browser runs a "evil" javascript by attacker. Can the attacker use this to steal victim's secret (like password)?
Wonder if it's possible to make the "evil" javascript send multiple requests of different lengths to reveal the secret.
For example, suppose the password is "123". In order to reveal the secret to the sniffer, the "evil" javascript will
-- craft a request of length 500 bytes, based on the encrypted length, sniffer may guess first digit is 1.
-- creaft a request of length 600, sniffer may guess second digit is 2, and so on.
To improve the odds, evil javascript may wait a little for traffic to clear (i.e. all elements of the pages to finish loading).
This will not depending on compression algorithm used.
Thanks.