• Neville Flynn (unregistered)

    It's necessary to do it this way for embedded systems.

  • (cs) in reply to Mark Harrison
    Mark Harrison:
    TRWTF is offcourse it only catches 'IndexOutOfRangeException', what about FileNotFound?

    I suppose though that in this case as passwords are so special, it should be fish, or even more likely phish.

  • Sales guy (unregistered)

    My password is just the letter 'a'.

  • Aceof♥s (unregistered) in reply to BG
    BG:
    In TheDailyWTF comment system you can type your password in and it appears as *'s!. For instance, if you typed 'hunter2' it would appear to me as '*******'
    BG♥sCoCK

    Did it work?

  • Dave (unregistered) in reply to Scott

    Believe it or not, this is how TD Canada Trust's (Canada's second largest financial institution) online banking works.

    They only allow for a password up to 8 characters. If you enter more than 8 characters the system truncates anything beyond 8 chars and validates.

    Other things about TD Canada Trust's passwords:

    1. Password can only be 5-8 characters in length
    2. no special characters are allowed
    3. System does not differentiate between upper and lower case.

    I've raised these issues with their support team however they state that these faults are actually features. They even said that because hundreds of people forget their passwords that they are willing to sacrifice a little security for ease of use.

  • ************** (unregistered) in reply to barc0de
    barc0de:
    BG:
    In TheDailyWTF comment system you can type your password in and it appears as *'s!. For instance, if you typed 'hunter2' it would appear to me as '*******'

    Haha, very funny, do you really think i would give you my ******** that easily


    Dear barc0de,

    In case you can’t tell, this is a grown-up place. The fact that you insist on using your ridiculous handle clearly shows that you’re too young and too stupid to be using thedailywtf.com.

    Go away and grow up.

    Sincerely,


  • Hashini (unregistered)

    hunglikeahorse

    oh cool it works!

  • Webdude (unregistered) in reply to Sales guy
    Sales guy:
    My password is just the letter 'a'.

    Sales guy, I've reset your password to "password".

  • (cs) in reply to Dave
    Dave:
    Believe it or not, this is how TD Canada Trust's (Canada's second largest financial institution) online banking works.

    They only allow for a password up to 8 characters. If you enter more than 8 characters the system truncates anything beyond 8 chars and validates.

    Other things about TD Canada Trust's passwords:

    1. Password can only be 5-8 characters in length
    2. no special characters are allowed
    3. System does not differentiate between upper and lower case.

    I've raised these issues with their support team however they state that these faults are actually features. They even said that because hundreds of people forget their passwords that they are willing to sacrifice a little security for ease of use.

    5-8 characters, also makes sense. No sense in using more characters than your average user can count up to.

    No special characters allowed, makes sense also it is after all a pass 'word' not a pass '%_Qw987-P='

    ignore case - this feature makes sense, this way your typical Canuckistani CAN LEAVE THE CAPS LOCK KEY ON AT ALL TIMES

  • highphilosopher (unregistered) in reply to frits
    frits:
    You guys laugh, but this is the exact code the CLR uses for String.Equals(), except they use a loop over a switch for optimization.

    This is nothing like the code that .NET uses for String.Equals(). They call an internal unsafe method called EqualsHelper() which does a while loop over the two Char arrays to check them character by character.

  • evilspoons (unregistered) in reply to JSelf
    JSelf:
    ctrl+c/v the ********

    Whatever version of Netscape my junior high school had installed on their Mac Colour Classic IIs actually let you do this. Someone had typed in a password on a web page then walked away from the computer. CMD-C and CMD-V and it actually showed up in the address bar. I couldn't believe it.

  • (cs)

    The company-wide common code library is TRWTF.

  • Ken (unregistered)

    So if I pass two empty strings it will return false?

  • boog (unregistered) in reply to Anonymous
    Anonymous:
    I like to think that there's always a more complicated way to do string comparisons. Comparing byte arrays is a nice over-complication but I've seen better.
    You said it. I'm sure he could have used recursion somewhere.
  • wtf (unregistered) in reply to Dave
    Dave:
    Believe it or not, this is how TD Canada Trust's (Canada's second largest financial institution) online banking works.

    They only allow for a password up to 8 characters. If you enter more than 8 characters the system truncates anything beyond 8 chars and validates.

    Oh, my.
    Other things about TD Canada Trust's passwords:
    1. Password can only be 5-8 characters in length
    Oh, dear.
    2) no special characters are allowed

    Oh my goodness.

    3) System does not differentiate between upper and lower case.

    Oh, my stars and garters.

    I've raised these issues with their support team however they state that these faults are actually features. They even said that because hundreds of people forget their passwords that they are willing to sacrifice a little security for ease of use.

    If the bank wants to give user passwords away, why don't they just sell the password file? It would probably be worth a few nickels.

  • whiskeyjack (unregistered) in reply to Hashini
    Hashini:
    hunglikeamouse oh cool it works!

    FTFY.

  • String.equals (unregistered) in reply to highphilosopher
    highphilosopher:
    frits:
    You guys laugh, but this is the exact code the CLR uses for String.Equals(), except they use a loop over a switch for optimization.

    This is nothing like the code that .NET uses for String.Equals(). They call an internal unsafe method called EqualsHelper() which does a while loop over the two Char arrays to check them character by character.

    Actually to be pedantic it does full int comparisons for the bulk of the string then Chars for the rest.

    Also it has the whole pass1.Length != pass2.Length check that that might have (slightly) improved the original code.

  • Antony Koch (unregistered) in reply to BG
    BG:
    In TheDailyWTF comment system you can type your password in and it appears as *'s!. For instance, if you typed 'hunter2' it would appear to me as '*******'

    Ahah!, good ol' bash.org

  • Larry (unregistered)

    TRWTF is recycling.

  • (cs) in reply to highphilosopher
    highphilosopher:
    frits:
    You guys laugh, but this is the exact code the CLR uses for String.Equals(), except they use a loop over a switch for optimization.

    This is nothing like the code that .NET uses for String.Equals(). They call an internal unsafe method called EqualsHelper() which does a while loop over the two Char arrays to check them character by character.

    Then frits is right, jackass. Or do you think there's a meaningful difference between a while loop and the implementation in the sample?

    The RWTF here is not using the built-in library.

  • (cs)

    Corrected catch block:

    catch (IndexOutOfRangeException ex) { throw new OhMyGodStringsAreActuallyDifferentLengthsException("something went horribly wrong", ex); }

  • boog (unregistered) in reply to Cbuttius
    Cbuttius:
    The Nerve:
    public static bool passwordsMatch(string pass1, string pass2)
    {
        return pass1.Equals(pass2);
    }
    
    Not the same logic. pass1 must be a left-subset of pass2 but doesn't have to be equal to it.
    You're joking (I hope), but I've worked with developers who, if you suggested replacing the original code (their code) with the above fix, would use the difference in logic as a justification NOT to allow the fixed code. Never mind that it's the original's logic that is flawed.
  • Chris (unregistered)

    In some systems it actually is important to hold passwords as something other than String. Because in Java and C# String is immutable, it's rather difficult to remove the password from memory once it is no longer needed. That opens it up to attack from eg malware that scans the PC's memory (or possibly worse, swapfile). If the password is captured into a char[] instead, the array can be overwritten as soon as it is finished with.

  • MrSoundless (unregistered)

    I guess this is much shorter!

    public static bool passwordsMatch(string pass1, string pass2) { return pass2.StartsWith(pass1); }

  • MeBerserk (unregistered) in reply to BG

    LOL @ IRC Bash =)

  • blabla (unregistered)

    This is actually the same bug as a bug in Windows 95/98/ME.

    "File and Print Sharing service in Windows 95, Windows 98, and Windows Me does not properly check the password for a file share, which allows remote attackers to bypass share access controls by sending a 1-byte password that matches the first character of the real password, aka the "Share Level Password" vulnerability."

    (http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2000-0979)

  • JB (unregistered) in reply to SR
    SR:

    isecretlylikejustinbeiber

    i secretly like just in beiber

    what do you mean by "in beiber"?

  • (cs) in reply to Chris
    Chris:
    In some systems it actually is important to hold passwords as something other than String. Because in Java and C# String is immutable, it's rather difficult to remove the password from memory once it is no longer needed. That opens it up to attack from eg malware that scans the PC's memory (or possibly worse, swapfile). If the password is captured into a char[] instead, the array can be overwritten as soon as it is finished with.
    Which is why .Net has System.Security.SecureString.
  • v (unregistered)

    In fact passwords should be treated differently: you should use a constant time comparison (e.g. not returning once a mismatched character is found as in the above)

  • Larry (unregistered) in reply to v
    v:
    In fact passwords _should_ be treated differently: you should use a constant time comparison (e.g. not returning once a mismatched character is found as in the above)
    TRWTF is machines that would take more than a nanosecond to process two > 1,000-character passwords.
  • Bob (unregistered) in reply to v
    v:
    In fact passwords _should_ be treated differently: you should use a constant time comparison (e.g. not returning once a mismatched character is found as in the above)
    What kind of squirrely, hypothetical fantasy world do you live in? Any cracker that attempted to break the password this way would be confounded by the packet latency that would take place between the submit and the return. THAT ITSELF is a variable time parameter, and would completely prempt any time-based "cracking" algorithm.
  • spameggs (unregistered) in reply to Bob
    Bob:
    v:
    In fact passwords _should_ be treated differently: you should use a constant time comparison (e.g. not returning once a mismatched character is found as in the above)
    What kind of squirrely, hypothetical fantasy world do you live in? Any cracker that attempted to break the password this way would be confounded by the packet latency that would take place between the submit and the return. THAT ITSELF is a variable time parameter, and would completely prempt any time-based "cracking" algorithm.

    Sure? http://www.itbusiness.ca/it/client/en/home/news.asp?id=58406

  • Bob (unregistered) in reply to spameggs
    spameggs:
    Bob:
    v:
    In fact passwords _should_ be treated differently: you should use a constant time comparison (e.g. not returning once a mismatched character is found as in the above)
    What kind of squirrely, hypothetical fantasy world do you live in? Any cracker that attempted to break the password this way would be confounded by the packet latency that would take place between the submit and the return. THAT ITSELF is a variable time parameter, and would completely prempt any time-based "cracking" algorithm.

    Sure? http://www.itbusiness.ca/it/client/en/home/news.asp?id=58406

    That article is B.S. Fiction written to sell more software.

  • v (unregistered) in reply to Bob

    A world in which people learn about statistics, and know a tiny bit about computer security. There have been a few, well publicized timing vulnerabilities in the last few years.

  • (cs)

    I just had flashbacks of finding code like this in a particular web system. At first, I wondered why this would work, as it didn't encrypt/hash the password. Then it dawned in me...

    the passwords were stored in clear text.

  • Bob (unregistered) in reply to v
    v:
    A world in which people learn about statistics, and know a tiny bit about computer security. There have been a few, theorized timing vulnerabilities in the last few years.
    FTFY
  • (cs) in reply to hoodaticus

    It was a joke.

    Addendum (2010-09-15 12:28): You would think the whole "loop over a switch" thing would be a tip off.

  • v (unregistered) in reply to Bob

    Attacks were mounted, keys were recovered, please don't ever write security code, thanks.

  • BG (unregistered) in reply to Aceof♥s
    Aceof♥s:
    BG:
    In TheDailyWTF comment system you can type your password in and it appears as *'s!. For instance, if you typed 'hunter2' it would appear to me as '*******'
    BG♥sCoCK

    Did it work?

    It depends. What are you doing this Saturday?

  • (cs) in reply to Steve H
    Steve H:
    BG:
    In TheDailyWTF comment system you can type your password in and it appears as *'s!

    Weird! Where does the completely spurious apostrophe come from?


    it is the manifestation of the world's dislike for you.

  • boog (unregistered) in reply to frits
    frits:
    You would think the whole "loop over a switch" thing would be a tip off.
    They apparently haven't heard of the for-switch paradigm (or for-case, if you prefer).
  • (cs) in reply to hoodaticus
    hoodaticus:
    highphilosopher:
    frits:
    You guys laugh, but this is the exact code the CLR uses for String.Equals(), except they use a loop over a switch for optimization.

    This is nothing like the code that .NET uses for String.Equals(). They call an internal unsafe method called EqualsHelper() which does a while loop over the two Char arrays to check them character by character.

    Then frits is right, jackass. Or do you think there's a meaningful difference between a while loop and the implementation in the sample?

    The RWTF here is not using the built-in library.

    No, frits said "over a switch statement", which would be different. But he was just being cheeky.

    And highphilosopher pointed out that the internal String.Equals uses unsafe code, which allows it to use pointers for performance. He may have missed the sarcasm, but there's no need to get nasty.

  • Fred (unregistered) in reply to Steve H
    Steve H:
    BG:
    In TheDailyWTF comment system you can type your password in and it appears as *'s!

    Weird! Where does the completely spurious apostrophe come from?

    it's a contraction of **s. He means that that the password appears as pairs of stars

  • (cs) in reply to Dave
    barc0de:
    BG:
    In TheDailyWTF comment system you can type your password in and it appears as *'s!. For instance, if you typed 'hunter2' it would appear to me as '*******'

    Haha, very funny, do you really think i would give you my ******** that easily

    LOL. That's a wonderful response to that meme; I may have to steal it.

    Dave:
    I've raised these issues with their support team however they state that these faults are actually features. They even said that because hundreds of people forget their passwords that they are willing to sacrifice a little security for ease of use.
    Why are you still using them as a bank? (Or are you?)

    Kohls only allows up to 8 characters for their credit card site, but at least distinguishes case and it allows at least some special characters. Usually I do some things that decrease the entropy over a completely random n-character password (like make it pronounceable), but with them I keep as much strength as I could figure out I could.

    When it comes to banks, there are enough that I would have no compunction about closing my account and moving to another bank over that issue.

  • Important Sales Guy (unregistered)

    While I understand the need for security, I think after three tries my computer should let me in anyway. After all it is my computer, and you software geeks need to face reality and understand that I have important deals to close and I can't be bothered typing my password over and over all day long whenever I go to my bank, or stock broker, or the gaming and pr0n sites that keep me on my edge.

  • someGuy (unregistered)

    Timing Attacks are BS.

    Could someone devise a test on a closed system, while in control of every aspect of the network infrastructure, with the ability to reduce as much noise as possible?

    perhaps

    could you utilize those techniques to crack a password at Digg.com?

    no.

    The complexity of filtering out the noise is exponentially higher. Heck, even the interrupt coalescing algorithm (that is likely running on the network driver on the server you are connecting to) will introduce noise orders of magnitude greater than the change in processing time from getting a character correct.

  • (cs)

    Obviously, everyone knows that if a.length != b.length you should return false even before starting the loop.

    Correct implementation of equals (for ascii):

    bool equals(String lhs, String rhs) {
         if(rhs.length() != lhs.length()) return false;
         
         for(idx_t i = 0; i < lhs.length(); ++i) {
             if(rhs.at(i) != lhs.at(i)) return false;
         }
         return true;
    }
    

    Please tell me it's correct. It's correct, right?

  • (cs) in reply to SeySayux
    SeySayux:
    Obviously, everyone knows that if a.length != b.length you should return false even before starting the loop.

    Correct implementation of equals (for ascii):

    bool equals(String lhs, String rhs) {
         if(rhs.length() != lhs.length()) return false;
         
         for(idx_t i = 0; i < lhs.length(); ++i) {
             if(rhs.at(i) != lhs.at(i)) return false;
         }
         return true;
    }
    

    Please tell me it's correct. It's correct, right?

    You can optimize and use an object comparison. If (object)rhs == (object)lhs you can go ahead and return true immediately.

  • airdrik (unregistered)
    //This should guarantee that they can't use time-based attacks to get at our passwords!
    public boolean arePasswordsEqual(String pass1, String pass2)
    {
      for(String possiblePassword : passwordGenerator.passwordsOfLength(pass1.length))
      {
        if(pass1.Equals(possiblePassword) && pass2.Equals(pass2))
           return true;
      }
      return false;
    }
    

    Oh, and passwordGenerator just pulls the passwords from the database table which has the password and its hash code for easy look up. That way it's Fast and Secure!

  • Mike (unregistered)
    public static bool passwordsMatch(string pass1, string pass2) {
      // bgates : TODO - add security stuff 
      return true;
    }
    

Leave a comment on “Very Special Strings”

Log In or post as a guest

Replying to comment #:

« Return to Article