Skip to content

x-xsrf-token: token is added even for other origins.  #15052

Closed

Description

@bhoomabrsr

There is no check for urlIsSameOrigin or not, before appending to request headers in the CookieXSRFStrategy

Please check out this plunker: https://plnkr.co/edit/vhiBHiVpt598FS15orFX?p=preview

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

x-xsrf-token: token is added even for other origins
Expected behavior

it should not added if URL origin is different.

Minimal reproduction of the problem with instructions

Please check out this plunker: https://plnkr.co/edit/vhiBHiVpt598FS15orFX?p=preview

  • Angular version: Angular v2.4.9

Activity

  1. DzmitryShylovich commented on Mar 9, 2017

    @DzmitryShylovich
    Contributor

    Please fill out the issue template. thanks

  2. bhoomabrsr commented on Mar 9, 2017

    @bhoomabrsr
    Author

    Updated with template.

  3. self-assigned this
    on Apr 1, 2017
  4. dherges commented on Apr 24, 2017

    @dherges
    Contributor

    For clarification: same origin should be determined by cookie's domain value (i.e. run.plnkr.co in your example). Thing is: we cannot read domain value in JavaScript, right?

    (thinking loud)

    Is it enough to do same-origin check for the URL of the request? XHR is cross-origin when URL starts with either http: or https: or //. If URL starts with anything else, request can be considered same origin.

    However, this will potentially break sub-domain set ups (e.g. cookie set for .domain.com, XHR to //sub.domain.com/foo). Given the definition of origins for cookies, we'd need to extract the domain + public suffix (e.g. domain.co.uk) and check whether document.domain is same domain or sub-domain of this?

  5. zenlambda commented on Jun 10, 2017

    @zenlambda

    Is there a work around for this? (Besides using XHR or fetch).

  6. alxhub commented on Dec 5, 2017

    @alxhub
    Member

    This is fixed in HttpClient.

  7. angular-automatic-lock-bot commented on Sep 12, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  8. locked and limited conversation to collaborators on Sep 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions