Dangerous Errors
Podcast Posts Presentations Synthwave About
Podcast Posts Presentations Synthwave About
  • Bad Code Entitles Good Exploits Sep 9, 2014

    Here's an HTML injection (aka cross-site scripting) example that's due to a series of tragic assumptions that conspire to not only leave the site vulnerable, but waste lines of code doing so.

    The first clue to the flaw lies in the querystring's state parameter. The site renders the state value into a title element. Naturally, a first test payload for HTML injection would be attempting to terminate that element. If that works, then a more impactful followup would be to append arbitrary markup such as <script> tags. A simple probe looks like this:

    https://web.site/cg/aLink.do?state=abc%3C/title%3E

    The site responds by stripping the payload's </title> tag and all subsequent characters. Only the text leading up to the injected tag is rendered within the title.

    <HTML>
    <HEAD>
    <TITLE>abc</TITLE>
    

    This seems to have effectively countered the attack. Of course, if you've been reading this blog for a while, you'll suspect this initial countermeasure won't hold up -- that which seems secure shatters under scrutiny.

    The developers worried that an attacker might try to inject a closing </title> tag. Consequently, they created a filter to watch for such payloads and strip them. This could be implemented as a basic case-insensitive string comparison or a trivial regex.

    And it could be bypassed by just a few characters.

    Consider the following closing tags. Regardless of whether they seem surprising or silly, the extraneous characters are meaningless to HTML yet meaningful to our exploit because they belie the assumption that regexes make good parsers.

    <%00/title>
    <""/title>
    </title"">
    </title id="">
    

    After inspecting how the site responds to each of the above payloads, it's apparent that the filter only expected a so-called "good" </title> tag. Browsers don't care about an attribute on the closing tag. They'll ignore such characters as long as they don't violate parsing rules.

    Next, we combine the filter bypass with a payload. In this case, we'll use an image onerror event.

    https://web.site/cg/aLink.do?state=abc%3C/title%20id=%22a%22%3E%3Cimg%20src=x%20onerror=alert%289%29%3E

    The attack works! We should have been less sloppy and added an opening <TITLE> tag to match the newly orphaned closing one. A nice exploit won't leave the page messier than it was before.

    <HTML>
    <HEAD>
    <TITLE>abc</title id="a">
    <img src=x onerror=alert(9)>
    Vulnerable & Exploited Information Resource Center</TITLE>
    

    The tragedy of this flaw is that it shows how the site's developers were aware of the concept of HTML injection exploits, but failed to grasp the underlying principles of the vuln. The effort spent blocking an attack (i.e. countering an injected closing tag) not only wasted lines of code on an incorrect fix, but instilled a false sense of security. The code became more complex and less secure.

    The mistake also highlights the danger of assuming that well-formed markup is the only kind of markup. Browsers are capricious beasts. They must dance around typos, stomp upon (or skirt around) errors, and walk bravely amongst bizarrely nested tags. This syntactic havoc is why regexes are notoriously worse at dealing with HTML than proper parsers.

    There's an ancillary lesson here in terms of automated testing (or quality manual pen testing, for that matter). A scan of the site might easily miss the vuln if it uses a payload that the filter blocks, or doesn’t apply any attack variants. This is one way sites "become" vulnerable when code doesn't change, but attacks do.

    And it's one way developers must change their attitudes from trying to outsmart attackers to focusing on basic security principles.

  • RSA APJ 2014, CDS-W07 Slides Jul 30, 2014

    Here are the slides for my presentation, "Building and Breaking Privacy Barriers", at this year's RSA Asia Pacific and Japan conference in Singapore.

    The slides convey more theory than practical examples, but the ideas should come across without too much confusion. I expect to revisit the idea of a Rot network (a play on Tor) and toy with an implementation. Instead of blocking tracking bugs, the concept is to reduce their utility by sharing them across unrelated browsers -- essentially polluting the data.

    In any case, with this presentation over and out of the way, it's time to start working on more articles!

  • A Monstrous Confluence May 10, 2014

    You taught me language, and my profit on't

    Is, I know how to curse: the red plague rid you,

    For learning me your language!

    -- Caliban (The Tempest, I.ii.363-365)

    The announcement of the Heartbleed vulnerability revealed a flaw in OpenSSL that could be exploited by a simple mechanism against a large population of targets to extract random memory from the victim. At worst, that pilfered memory would contain sensitive information like HTTP requests (with cookies, credentials, etc.) or even parts of the server’s private key. Or malicious servers could extract similarly sensitive data from vulnerable clients.

    In the spirit of Caliban, Shakespeare's freckled whelp, I combined a desire to learn about Heartbleed’s underpinnings with my ongoing experimentation with the new language features of C++11. The result is a demo tool named Hemorrhage.

    Hemorrhage shows two different approaches to sending modified TLS heartbeats. One relies on the Boost.ASIO library to set up a TCP connection, then handles the SSL/TLS layer manually. The other uses a more complete adoption of Boost.ASIO and its asynchronous capabilities. It was this async aspect where C++11 really shone. Lambdas made setting up callbacks a pleasure — especially in terms of readability compared to prior techniques that required binds and placeholders.

    Readable code is hackable (in the creation sense) code. Being able to declare variables with auto made code easier to read, especially when dealing with iterators. Although hemorrhage only takes minimal advantage of the move operator and unique_ptr, they are currently my favorite aspects following lambdas and auto.

    Hemorrhage itself is simple. Check out the README.md for more details about compiling it. (As long as you have Boost and OpenSSL it should be easy on Unix-based systems.)

    The core of the tool is taking the tls1_heartbeat() function from OpenSSL's ssl/t1_lib.c file and changing the payload length — essentially a one-line modification. Yet another approach might be to use the original tls1_heartbeat() function and modify the heartbeat data directly by manipulating the SSL* pointer's s3->wrec data via the SSL_CTX_set_msg_callback().

    In any case, the tool's purpose was to "learn by implementing something" as opposed to crafting more insidious exploits against Heartbleed. That's why I didn’t bother with more handshake protocols or STARTTLS. It did give me a better understanding of OpenSSL's internals. But still, I'll add my voice to the chorus bemoaning its readability.

  • RSA USA 2014, DSP-R04A Slides Feb 28, 2014

    Here are the slides for my presentation, DSP-R04A Is Your Browser a User Agent or a Double Agent?, at this year's RSA USA conference in San Francisco.

    This departed from a security focus into the realm of privacy, noting how browsers struggle (or not) against tracking mechanisms and how various organizations build views of web site visitors.

  • Audit Accounts, Partition Passwords, Stay Secure Jan 6, 2014

    It’s a new year, so it’s time to start counting days until we hear about the first database breach of 2014 to reveal a few million passwords. Before that inevitable compromise happens, take the time to clean up your web accounts and passwords. Don't be a prisoner to bad habits.

    There's no reason to reuse a password across any account. Partition your password choices so that each account on each web site uses a distinct value. This prevents an attacker who compromises one password (hashed or otherwise) from jumping to another account that uses the same credentials.

    Penny-farthing

    At the very least, your email, Facebook, and Twitter accounts should have different passwords. Protecting email is especially important because so many sites rely on it for password resets.

    And if you’re still using the password kar120c I salute your sci-fi dedication, but pity your password creation skills.

    Next, consider improving account security through the following steps.

    Consider Using OAuth — Passwords vs. Privacy

    Many sites now support OAuth for managing authentication. Essentially, OAuth is a protocol in which a site asks a provider (like Facebook or Twitter) to verify a user’s identity without having to reveal that user’s password to the inquiring site. This way, the site can create user accounts without having to store passwords. Instead, the site ties your identity to a token that the provider verifies. You prove your identify to Facebook (with a password) and Facebook proves to the site that you are who you claim to be.

    If a site allows you to migrate an existing account from a password-based authentication scheme to an OAuth-based one, make the switch. Otherwise, keep this option in mind whenever you create an account in the future.

    But there’s a catch. A few, actually. OAuth shifts a site’s security burden from password management to token management and correct protocol implementation. It also introduces privacy considerations related to centralizing auth to a provider as well as how much providers share data.

    Be wary about how sites mix authentication and authorization. Too many sites ask for access to your data in exchange for using something like Facebook Connect. Under OAuth, the site can assume your identity to the degree you’ve authorized, from reading your list of friends to posting status updates on your behalf.

    Grant the minimum permissions whenever a site requests access (i.e. authorization) to your data. Weigh this decision against your desired level of privacy and security. For example, a site or mobile app might insist on access to your full contacts list or the ability to send Tweets. If this is too much for you, then forego OAuth and set up a password-based account.

    (The complexity of OAuth has many implications for users and site developers. We’ll return to this topic in future articles.)

    Two-Factor Auth — One Equation in Two Unknowns

    Many sites now support two-factor auth for supplementing your password with a temporary passcode. Use it. This means that access to your account is contingent on both knowing a shared secret (the password you’ve given the site) and being able to generate a temporary code.

    Your password should be known only to you because that’s how you prove your identity. Anyone who knows that password — whether it’s been shared or stolen — can use it to assume your identity within that account.

    A second factor is intended to be a stronger proof of your identity by tying it to something more unique to you, such as a smartphone. For example, a site may send a temporary passcode via text message or rely on a dedicated app to generate one. (Such an app must already have been synchronized with the site; it’s another example of a shared secret.) In either case, you’re proving that you have access to the smartphone tied to the account. Ideally, no one else is able to receive those text messages or generate the same sequence of passcodes.

    The limited lifespan of a passcode is intended to reduce the window of opportunity for brute force attacks. Imagine an attacker knows the account’s static password. There’s nothing to prevent them from guessing a six-digit passcode. However, they only have a few minutes to guess one correct value out of a million. When the passcode changes, the attacker has to throw away all previous guesses and start the brute force anew.

    The two factor auth concept is typically summarized as the combination of “something you know” with “something you possess”. It really boils down to combining “something easy to share” with “something hard to share”.

    Beware Password Recovery — It's Like Shouting Secret in a Crowded Theater

    If you’ve forgotten your password, use the site’s password reset mechanism. And cross your fingers that the account recovery process is secure. If an attacker can successfully exploit this mechanism, then it doesn’t matter how well-chosen your password was (or possibly even if you’re relying on two-factor auth).

    If the site emails you your original password, then the site is insecure and its developers are incompetent. It implies the password has not even been hashed.

    If the site relies on security questions, consider creating unique answers for each site. This means you’ll have to remember dozens of question/response pairs. Make sure to encrypt this list with something like the OS X Keychain.

    Review Your OAuth Grants

    For sites you use as OAuth providers (like Facebook, Twitter, Linkedin, Google+, etc.), review the third-party apps to which you’ve granted access. You should recognize the sites that you’ve just gone through a password refresh for. Delete all the others.

    Where possible, reduce permissions to a minimum. You’re relying on this for authentication, not information leakage.

    Use HTTPS

    Universal adoption of HTTPS remains elusive. Fortunately, sites like Facebook and Twitter have set this by default. If the site has an option to force HTTPS, use it. After all, if you’re going to rely on these sites for OAuth, then the security of these accounts becomes paramount.

    Maintain Constant Vigilance

    Keep your browser secure. Keep your system up to date. Set a reminder to go through this all over again a year from now — if not earlier.

    Otherwise, you risk losing more than one account should your password be exposed among the millions. You are not a number, you’re a human being.

1 ... 13 14 15 16 17 ... 28

Dangerous Errors

  • zombie
  • mutantzombie
  • mutantzombie.bsky.app
  • SecurityWeekly

Cybersecurity and more | © Mike Shema