Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All calls to /envelope blocked by CSRF #598

Closed
walkerdb opened this issue Jul 15, 2020 · 8 comments
Closed

All calls to /envelope blocked by CSRF #598

walkerdb opened this issue Jul 15, 2020 · 8 comments

Comments

@walkerdb
Copy link

walkerdb commented Jul 15, 2020

versions involved:

  • sentry onpremise 20.7.0 (45e45d1), deployed in a k8s cluster. We've configured it to include the performance tab, by turning on organizations:performance-view
  • frontend: @sentry/react and @sentry/apm, both at 5.19.1

From the browser, requests to api/[project-id]/store for js errors work fine. However, perf tracing requests to api/[project-id]/envelope fail with a 403. The 403 response has some html about a CSRF token not being set:

Screen Shot 2020-07-15 at 4 04 44 PM

From the outside it seems like the request validation path for the two endpoints are different. Is there additional config we need to set on our end for this to work, or is the issue somewhere else? Is the JS lib supposed to have some communication from the backed to get a CSRF token before sending the /envelope requests?

our browser config:

import * as Sentry from '@sentry/react'; 
import { Integrations } from '@sentry/apm'; 

Sentry.init({
  dsn: 'https://[id]@[host]/[project-number]',
  release: 'some-git-hash',
  environment: 'sandbox',
  integrations: [
    new Integrations.Tracing(),
  ],
  tracesSampleRate: 1.0, // for testing, will turn down before going live
});
@walkerdb walkerdb changed the title All calls to /envelope blocked by CSRF All calls to /envelope blocked by CSRF Jul 15, 2020
@walkerdb
Copy link
Author

walkerdb commented Jul 15, 2020

Wondering if the server nginx directive needs an entry for /envelope: https://github.com/getsentry/onpremise/blob/master/nginx/nginx.conf#L60

edit: nvm; should be caught be the location ~ ^/api/[1-9]\d*/ line

@walkerdb
Copy link
Author

update: this may be unrelated to onpremise, but instead some k8s ingress config. Feel free to ignore for now; will post back here after we've done some investigation on our end.

@BYK
Copy link
Collaborator

BYK commented Jul 17, 2020

I was able to use performance with the current on-premise setup so I think this is related to your k8s setup as you mentioned.

Closing for now but I'll reopen if it turns out there's something we need to fix.

@BYK BYK closed this as completed Jul 17, 2020
@chhetripradeep
Copy link

@walkerdb i am seeing the same issue while trying to upgrade to latest release

03:46:10 [WARNING] django.security.csrf: Forbidden (Referer checking failed - no Referer.): /api/7/store/ (status_code=403 request=<WSGIRequest: POST u'/api/7/store/'>)

Can you share what config change helped you in fixing the issue.

Thank you.

@walkerdb
Copy link
Author

walkerdb commented Jul 29, 2020

@chhetripradeep we're using sentry-kubernetes helm charts for deploying, and we believe we ran into this issue because they don't yet have relay support. There's a PR in the works that we think will fix our issue here: sentry-kubernetes/charts#130

If you're not using those then you may need to manually make sure you have relay running and configured correctly. But generally at least for us it's unrelated to this on-premise repo.

@chhetripradeep
Copy link

Hi @walkerdb thank you for your quick response. We have our own internal helm chart which doesnt use relay. Is relay a mandatory component now ? My understanding was that it was an optional component.

@walkerdb
Copy link
Author

walkerdb commented Jul 29, 2020

@chhetripradeep My understanding is that as of sentry v20.7 some details of how sentry manages CSRF changed internally. It works correctly when using relay, but if you're using something like a k8s nginx ingress point you may be able to get it working with the right config tweaking. Not sure what that would need to be.

@chhetripradeep
Copy link

Thank you so much @walkerdb for quick responses. I came across this issue #590 and looks like relay is a mandatory thing from 20.7. Thank you again for your help.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants