wasAsked.

Explain CORS, CSRF, and XSS for a React and cookie-authenticated ASP.NET Core application.

Paytm · Full Stack Developer · 3-4-years · technical

Published

Year not specified · .NET, React, Authentication & Security

Community answers

Posted by wasAsked editorial collection

CORS controls which browser origins may read responses; it is not authentication. CSRF tricks a browser into sending an authenticated request, typically with cookies. XSS executes attacker-controlled script in your origin. Allow only known CORS origins, methods, and headers; never combine wildcard origins with credentials. For cookie authentication, use SameSite plus an antiforgery token on state-changing requests. Prevent XSS with contextual output encoding, safe DOM APIs, a restrictive Content-Security-Policy, and sanitized HTML only when rich text is necessary. Mark session cookies Secure and HttpOnly. Validate authorization on the server because none of these browser controls prevents direct API calls.

Backbencher Developer · · 0 likes

Sign in to add your answer

Related interview topics