Likes Likes:  0
Resultaten 1 tot 5 van de 5
Geen

Onderwerp: Cross Site Cooking

  1. #1
    Michal Zalewski
    Cross Site Cooking
    Gast
    n/a Berichten
    Berichten zijn liked



    Thread Starter

    Cross Site Cooking


    (Why, yes, I came up with the name, and had to find some bugs to be able
    to post this.)

    Summary
    -------

    There are three fairly interesting flaws in how HTTP cookies were
    designed and later implemented in various browsers; these shortcomings
    make it possible (and alarmingly easy) for malicious sites to plant
    spoofed cookies that will be relayed by unsuspecting visitors to
    legitimate, third-party servers.

    Impact
    ------

    Many commercial websites may be attacked to overwrite or delete
    stored preferences, session identifiers, authentication data,
    cart contents - with results ranging from minor annoyances to
    a possibility of fraudulent activity, depending on site design
    (bugs #1 and #2).

    On sites where authentication data is tied on a server to a session ID,
    the attacker may be able to acquire credentials by tricking the
    visitor to authenticate within a session initiated by the attacker
    (bugs #1 and #2)

    Some websites may be susceptible to malicious-activity-by-proxy
    attacks (bug #3).

    There is no immediate universal threat to life as we know it, but
    numerous web scripts are an easy target of specific variants of the
    attacks described below.

    Discussion
    ----------

    Let's begin with a quick primer on cookie parsing: when a new cookie is
    issued to the browser (via "Set-Cookie" header in a HTTP response), the
    server is expected to specify the domain and URI for which the cookie is
    meaningful. This mechanism is present so that pages could limit the
    scope of their cookies if needed, and prevent the data from being sent
    to unrelated addresses in the same domain. For security purposes, the
    browser will (theoretically) reject a cookie that is set for a domain
    that is either defined too broadly, or does not match issuer's location
    at all.

    (In other words, http://www.example.com/ may set a cookie that will be
    sent to http://mail.example.com/, but not to http://forums.example.com/;
    it cannot configure a cookie to be sent to all .com servers, nor to an
    unrelated server, example.co.uk, however.)

    Problem #1 - trouble with these pesky foreigners
    ------------------------------------------------

    The mechanism for preventing overly relaxed cookie domain
    specification seems to be broken in all major browsers. Some ancient
    documents invoke the following flawed but reasonable rule:

    "Two dots are required if the top level domain is: .COM, .EDU, .NET,
    .ORG, .GOV, .MIL, or .INT. Three dots are required for any other
    domain. This is to prevent the subdomain from being set to something
    like .COM, the subdomain of all commercial machines."

    [ http://www.ciac.org/ciac/bulletins/i-034.shtml ]

    This is repeated ad nauseam in various cookie tutorials and FAQs,
    but my initial tests indicate that the rule is quite simply not true.
    Both MSIE and Firefox seem to be perfectly happy with two-period
    ccTLDs domain cookies (.xxx.xx).

    In other words, one can set a cookie for *.com.pl or *.com.fr, and
    override or corrupt credentials or other parameters on hundreds of
    thousands e-commerce websites in that country. It will be also
    possible to plant attacker's session ID on visitor's computer,
    and effectively, steal his credentials when he decides to sign in
    on the target site.

    Problem #2 - these cursed periods
    ---------------------------------

    Another twist on the story is that there is no checking if there's
    anything between periods in domain name - and extra trailing periods
    are accepted by most resolvers as a way to override local domain
    search path.

    One can set a cookie for ".com.", then bounce the visitor to
    http://www.victim.com./ . This address differs from the "real" one,
    and thus, unlike with #1, planted cookies would work only for this
    visit - but the trailing "." is not an alarming pattern for most
    users. In fact, seasoned users recognize it and sometimes purposefully
    append it - and as such, they won't be tempted to be suspicious, and
    may interact with the website (perhaps even authenticate within
    the session ID supplied by and known to the attacker).

    A surprise of sorts... I'm not the first person to spot this:
    http://www.nihongo.org/snowhare/utilities/triple_dot/ - credit
    goes to Benjamin Franz... vendors were notified in 1998, and certainly
    are not in a hurry to fix this.

    Ok, let's go back to cookie handling for a while...

    All the verification of domain path is limited to client-side; when
    the server receives a cookie ("Cookie" header in a HTTP request), there
    is no information about the original issuer. It is assumed that the
    browser behaves rationally, and is sending the cookie to a site or a set
    of sites that previously issued it. The only other option is that the
    user willingly tampered with the request, and is OK with any eventual
    consequences of his actions.

    This is a mistake.

    Problem #3 - it's the address that counts
    -----------------------------------------

    The attacker may easily force random visitors to accept and relay
    arbitrary cookies to a third-party site by a) setting up
    http://example.com; b) issuing all visitors a cookie that mimicks
    victim's cookies, but is valid for *.example.com; c) setting IN A
    record for evil.example.com to the IP address of its victim; d)
    redirecting users to http://evil.example.com. This will cause
    visitor's browser to send attacker's cookie to victim's server exactly
    as if it were a cookie originally issued by the victim himself.

    This trick alone does not compromise, disclose, erase, or supersede
    user's settings should he later access the site through its proper
    address; and since a bogus address is displayed in URL bar, the
    user is not tempted to interact with the website. (There are some
    brain-damaged examples of sessionID-in-URL redirects, but these
    have a fair share of other problems.)

    I do believe there is some risk, however: using this trick, a brand
    new identity may be temporarily bestowed upon the user, and used to
    perform certain undesirable or malicious tasks on the target site
    before he has a chance to object (hiding attacker's identity or
    bypassing IP-based limits). DDoS or session ID brute-forcing uses are
    also tempting.

    That said, this alone is not a major problem for a well-designed
    website and a savvy user; alas, websites should be designed with the
    knowledge of this possibility; and furhter research on specific
    applications of this technique to existing backends might be quite
    valuable.

    Well... that's the story...

    Solution
    --------

    Problem #1: There is no sane solution, other than altering HTTP cookie
    format so that the server gets a chance to figure out who issued that
    cookie in the first place. Workarounds by listing ccTLDs that use
    .xxx.xx/.xx.xx subdomains in the browser are better than nothing
    at all.

    Problem #2: Browsers should strip "idle" periods in cookie
    domain data. Browser vendors should take less than 8 years to address
    security problems.

    Problem #3: The immediate fix to this problem is requiring and carefully
    validating HTTP/1.1 "Host" header on all requests (this ensures that the
    browser's idea of who he's talking to matches the site's canonical
    name).

    Lame plug
    ---------

    http://lcamtuf.coredump.cx/silence/

    Cheers,
    /mz


  2. #2
    Michal Zalewski
    Cross Site Cooking
    Gast
    n/a Berichten
    Berichten zijn liked



    Thread Starter

    RE: Cross Site Cooking

    On Sun, 29 Jan 2006, Amit Klein (AKsecurity) wrote:

    > I tried setting a cookie for .com.pl, and I failed (that is, the browser
    > did not respect it). If you set a cookie for .kom.pl, it will be OK (if
    > you're in .kom.pl domain, that is).


    Amit,

    Mozilla/Firefox/Netscape are vulnerable to this flaw (and probably so is
    Konqueror). You are right in regard to MSIE 6, however - my apologies.

    I tested the vulnerability with *.com.pl for Firefox, and then followed up
    with a quicker test for *.ids.pl with MSIE, assuming it wouldn't implement
    such a kludge - my bad.

    So, to sum up - the first bug applies to Mozilla-based browsers, but not
    to MSIE; the other two bugs apply to all browsers.

    /mz

  3. #3
    Yngve Nysaeter Pettersen
    Cross Site Cooking
    Gast
    n/a Berichten
    Berichten zijn liked



    Thread Starter

    Re: Cross Site Cooking

    On Sun, 29 Jan 2006 01:50:23 +0100, Michal Zalewski <lcamtuf@dione.ids.pl>
    wrote:

    > Problem #1 - trouble with these pesky foreigners
    > ------------------------------------------------
    >
    > The mechanism for preventing overly relaxed cookie domain
    > specification seems to be broken in all major browsers. Some ancient
    > documents invoke the following flawed but reasonable rule:
    >
    > "Two dots are required if the top level domain is: .COM, .EDU, .NET,
    > .ORG, .GOV, .MIL, or .INT. Three dots are required for any other
    > domain. This is to prevent the subdomain from being set to
    > something
    > like .COM, the subdomain of all commercial machines."
    >
    > [ http://www.ciac.org/ciac/bulletins/i-034.shtml ]
    >
    > This is repeated ad nauseam in various cookie tutorials and FAQs,
    > but my initial tests indicate that the rule is quite simply not true.
    > Both MSIE and Firefox seem to be perfectly happy with two-period
    > ccTLDs domain cookies (.xxx.xx).
    >
    > In other words, one can set a cookie for *.com.pl or *.com.fr, and
    > override or corrupt credentials or other parameters on hundreds of
    > thousands e-commerce websites in that country. It will be also
    > possible to plant attacker's session ID on visitor's computer,
    > and effectively, steal his credentials when he decides to sign in
    > on the target site.


    When this problem was (to my knowlegde) first published in December 1998,
    this was called the "Cookie Monster Bug". See
    http://help.netscape.com/kb/consumer/19981231-1.html (the original
    advisory page is gone).

    The problem about the two internal dot rule for ccTLDs is that many ccTLDs
    are using a flat structure similar to the generic .com TLD, not a
    hierarchical structure like the one used by the .UK domain. To make
    matters worse, many ccTLDs are actually using a combination of the two
    structures.

    As far as I know there is no reliable algorithmic way to determine if a
    domain name is a valid domain (like company.tld) or a subTLD (like co.uk).
    One method could be a blacklist for common subTLDs like co.tld, com.tld,
    ac.tld, etc., but it is dificult to make such a list complete, and some
    ccTLDs also have multilevel subTLDs and also uses geographic names in such
    second level domains, e.g. city.state.us, and many countries have national
    names for their subTLDs. Last time I checked http://www.govcom.org/
    indicated that at least half of the ccTLDs had some form or hierarchical
    structure, but an unknown percentage of these are using a hybrid structure.

    Opera's current approach (which is not perfect) is to use a DNS lookup for
    non-generic (only those in Netscape's original list are considered generic
    in this context) that are either second level domains or two levels up
    from the server setting the cookie. If there is an IP address defined for
    the domain name, the cookie is accepted for the domain, otherwise it is
    only accepted for the server
    setting the cookie.

    We are investigating ways to improve on this method, but as far as I can
    tell, any improvement will require a coordinated effort by all the gTLD
    and ccTLD registries.


    > Problem #2 - these cursed periods
    > ---------------------------------


    > One can set a cookie for ".com.", then bounce the visitor to
    > http://www.victim.com./ . This address differs from the "real" one,
    > and thus, unlike with #1, planted cookies would work only for this
    > visit - but the trailing "." is not an alarming pattern for most


    In Opera this domain would be handled as described above, with a DNS
    lookup, and since ".com." will not resolve the cookie will only be
    accepted for the server setting the cookie.

    > Solution
    > --------
    >
    > Problem #1: There is no sane solution, other than altering HTTP cookie
    > format so that the server gets a chance to figure out who issued that
    > cookie in the first place. Workarounds by listing ccTLDs that use
    > .xxx.xx/.xx.xx subdomains in the browser are better than nothing
    > at all.


    RFC 2965, which is supported by Opera, already specifies such an extension
    to the cookie format. See http://www.ietf.org/rfc/rfc2965.txt for more
    details.

    --
    Sincerely,
    Yngve N. Pettersen

    ************************************************** ******************
    Senior Developer Email: yngve@opera.com
    Opera Software ASA http://www.opera.com/
    ************************************************** ******************

  4. #4
    Glynn Clements
    Cross Site Cooking
    Gast
    n/a Berichten
    Berichten zijn liked



    Thread Starter

    Re: Cross Site Cooking


    Yngve Nysaeter Pettersen wrote:

    > > Problem #1 - trouble with these pesky foreigners
    > > ------------------------------------------------
    > >
    > > The mechanism for preventing overly relaxed cookie domain
    > > specification seems to be broken in all major browsers. Some ancient
    > > documents invoke the following flawed but reasonable rule:
    > >
    > > "Two dots are required if the top level domain is: .COM, .EDU, .NET,
    > > .ORG, .GOV, .MIL, or .INT. Three dots are required for any other
    > > domain. This is to prevent the subdomain from being set to something
    > > like .COM, the subdomain of all commercial machines."
    > >
    > > [ http://www.ciac.org/ciac/bulletins/i-034.shtml ]
    > >
    > > This is repeated ad nauseam in various cookie tutorials and FAQs,
    > > but my initial tests indicate that the rule is quite simply not true.
    > > Both MSIE and Firefox seem to be perfectly happy with two-period
    > > ccTLDs domain cookies (.xxx.xx).
    > >
    > > In other words, one can set a cookie for *.com.pl or *.com.fr, and
    > > override or corrupt credentials or other parameters on hundreds of
    > > thousands e-commerce websites in that country. It will be also
    > > possible to plant attacker's session ID on visitor's computer,
    > > and effectively, steal his credentials when he decides to sign in
    > > on the target site.

    >
    > When this problem was (to my knowlegde) first published in December 1998,
    > this was called the "Cookie Monster Bug". See
    > http://help.netscape.com/kb/consumer/19981231-1.html (the original
    > advisory page is gone).
    >
    > The problem about the two internal dot rule for ccTLDs is that many ccTLDs
    > are using a flat structure similar to the generic .com TLD, not a
    > hierarchical structure like the one used by the .UK domain. To make
    > matters worse, many ccTLDs are actually using a combination of the two
    > structures.
    >
    > As far as I know there is no reliable algorithmic way to determine if a
    > domain name is a valid domain (like company.tld) or a subTLD (like co.uk).


    This is a meaningless distinction. No matter how many components a
    domain has, subdomains can still be delegated to distinct entities.

    For a university, should the student union website be sent cookies set
    by the registrar's site?

    If an ISP gives each customer a subdomain, should customers be sent
    each other's cookies? Does it matter how many components the ISP's
    domain has?

    [The correct answer to all of the above is "no".]

    The whole concept of trying to infer boundaries from the domain is
    broken by design. At least with the ancestor/descendent case, the
    administrators of the parent domain could alway redirect the entire
    domain to their own server, so you aren't really losing anything by
    allowing cookies to travel up or down the tree. But any mechanism
    which allows cookies to be transferred to "sibling" domains is
    fundamentally flawed.

    > One method could be a blacklist for common subTLDs like co.tld, com.tld,
    > ac.tld, etc., but it is dificult to make such a list complete, and some
    > ccTLDs also have multilevel subTLDs and also uses geographic names in such
    > second level domains, e.g. city.state.us, and many countries have national
    > names for their subTLDs. Last time I checked http://www.govcom.org/
    > indicated that at least half of the ccTLDs had some form or hierarchical
    > structure, but an unknown percentage of these are using a hybrid structure.
    >
    > Opera's current approach (which is not perfect) is to use a DNS lookup for
    > non-generic (only those in Netscape's original list are considered generic
    > in this context) that are either second level domains or two levels up
    > from the server setting the cookie. If there is an IP address defined for
    > the domain name, the cookie is accepted for the domain, otherwise it is
    > only accepted for the server
    > setting the cookie.
    >
    > We are investigating ways to improve on this method, but as far as I can
    > tell, any improvement will require a coordinated effort by all the gTLD
    > and ccTLD registries.


    Any improvement will require that browsers only pass cookies to
    domains which are explicitly permitted by the setter, and pass the
    setter domain to all recipients alongside the cookie. IOW, a protocol
    change. Anything else is papering over the cracks.

    --
    Glynn Clements <glynn@gclements.plus.com>

  5. #5
    Tim Nelson
    Cross Site Cooking
    Gast
    n/a Berichten
    Berichten zijn liked



    Thread Starter

    Re: Cross Site Cooking

    This message is in MIME format. The first part should be readable text,
    while the remaining parts are likely unreadable without MIME-aware tools.

    --0-464981713-1139189661=:30442
    Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed
    Content-Transfer-Encoding: 8BIT

    On Fri, 3 Feb 2006, Glynn Clements wrote:

    >> We are investigating ways to improve on this method, but as far as I can
    >> tell, any improvement will require a coordinated effort by all the gTLD
    >> and ccTLD registries.

    >
    > Any improvement will require that browsers only pass cookies to
    > domains which are explicitly permitted by the setter, and pass the
    > setter domain to all recipients alongside the cookie. IOW, a protocol
    > change. Anything else is papering over the cracks.


    What about using DNS records, either a new kind, or something
    TXT-based (like SPF). Maybe we could have it so that the domain owner
    could make an allow cookies record, with a list of matching domains, and
    if it doesn't exist, then the browser will only allow the cookie to be set
    for the full domain, not a subset of it.

    ?

    --
    Kind Regards,

    Tim Nelson
    Server Administrator

    P: 03 9934 0888
    F: 03 9934 0899
    E: tim.nelson@webalive.biz
    W: www.webalive.biz

    WebAlive Technologies
    Level 1, Innovation Building
    Digital Harbour
    1010 La Trobe Street
    Docklands Melbourne VIC 3008

    This email (including all attachments) is intended solely for the named addressee. It is confidential and may contain legally privileged information. If
    you receive it in error, please let us know by reply email, delete it from your system and destroy any copies. This email is also subject to copyright. No
    part of it should be reproduced, adapted or transmitted without the written consent of the copyright owner.

    Emails may be interfered with, may contain computer viruses or other defects and may not be successfully replicated on other systems. We give no
    warranties in relation to these matters. If you have any doubts about the authenticity of an email purportedly sent by us, please contact us immediately.

    --0-464981713-1139189661=:30442--

Webhostingtalk.nl

Contact

  • Rokin 113-115
  • 1012 KP, Amsterdam
  • Nederland
  • Contact
© Copyright 2001-2026 Webhostingtalk.nl.
Web Statistics