Why is Byte-at-a-time ECB decryption a vulnerability? I've been working on the Cryptopals Cryptography challenge problems, and I recently solved one where you recover a plaintext given a encryption oracle. The oracle produces a ciphertext in ECB mode AES.

You are given a base64 encoded piece of plaintext (encoded so that it isn't immediately human readable). The only thing you have control of is the plaintext you enter into the oracle. The key for AES is randomly generated each time, and you're not supposed to see it either.

More information on the problem here: Set 2, Challenge 12

What confuses me is that at the end of the problem a little box says 


  This is the first challenge we've given you whose solution will break
  real crypto. Lots of people know that when you encrypt something in
  ECB mode, you can see penguins through it. Not so many of them can
  decrypt the contents of those ciphertexts, and now you can. If our
  experience is any guideline, this attack will get you code execution
  in security tests about once a year.


How can this vulnerability be used in real life? To crack the plaintext, you need access to it, as well as an encryption oracle (which contains the key). Is it ever possible to have this much control over a system? And if you did, why couldn't you just directly print out the plaintext or key?
The vulnerability happens when:


You send an INPUT to the server.
The server appends secret to INPUT -&gt; INPUT||secret
The server encrypts it with a secret key -&gt; encrypt(INPUT||secret, key)
The server returns, or you get access in some way to the resulting cipher.


Let's assume the block size is 8. Steps;


All you have to do to decrypt the first byte of "secret" is to send a block of 7 bytes (block size -1). Let's assume we send: AAAAAAA. We get a cipher back, this cipher is our "target".
Next we try AAAAAAA with every other possible bytes: AAAAAAAA, AAAAAAAB, AAAAAAAC, ... Let's assume the cipher returned at STEP1 is the same as when we send AAAAAAAw. That means we know for sure the first byte of the secret is w. We discovered the first byte, yay!
Send 6 bytes (block-size - 1 - known bytes) + w (the byte we discovered previously). Get cipher.
Brute force the last byte until you know the second bytes...  Repeat all steps until you discovered secret.


See? We never actually needed to know the key and yet we discovered secret.

A concrete scenario where this could happens:

Website creates a secret code for each user for the duration of their session, but wants to remain stateless so it saves the code in their cookie, encrypted. Except that the cookie also contains the username (which the user can control/modify). Now the encrypted cipher is username||secret_code. Given this scenario, a user can easily find out what his secret_code is.