During one of our security reviews last month, the client's senior developer smiled and said, "We use React, XSS doesn't affect us." Two hours later, using content entered through the rich text editor in the site's blog section, we were running a script we had written ourselves inside the admin panel. Not because anyone was a bad developer (the team was perfectly competent) but because nobody knew the limits of the sense of security a framework provides.
We hear that sentence maybe ten times a year, and almost every time a case turns up that proves otherwise. XSS and CSRF, the web's two veteran attacks, didn't die on modern stacks; they changed shape. Understanding both properly once gives you a reflex that lasts for years.
XSS: someone else's code on your domain
The essence of cross-site scripting fits in one sentence: the attacker manages to inject JavaScript into your page through user input. From that moment on, the script runs with the victim's session and with all the reputation of your domain: it reads cookies, performs actions on the victim's behalf, changes page content and can listen to every keystroke. From the browser's point of view nothing is suspicious; the code is coming from your site.
The most dangerous variant is stored XSS: the malicious content is written to your database once and runs again and again for everyone who opens that page. Comment boxes, profile fields, product descriptions: every point where user content is stored and shown to others is a candidate. Compared with the reflected variant, which works on a single victim through a link, the blast radius is in a different league. Our blog case from the introduction was exactly this: the content was saved once and ran for every administrator who opened the panel.

Should we sell modern frameworks short? No: React, Vue and their peers escape variables by default when rendering them into templates, so most plain XSS cases die before they are born. The problem is that the escape hatches are well defined and well known: dangerouslySetInnerHTML in React, innerHTML on the vanilla side, javascript: links placed in href attributes and, the most classic of all, "trusted" HTML coming from the server. A function with "dangerously" in its name appearing in forty places in a project is a red alert for us in code review.
Every application that uses a rich text editor carries this risk structurally; you accept HTML from users and one day you will render it on a page. The rule is clear: sanitization happens on the server, at save time or at render time, using a proven library. Client-side sanitization is cosmetic; the attacker doesn't have to use your interface and can send requests straight to your API. On top of that, locking down script sources with a Content-Security-Policy header is the second seatbelt that limits the damage when something slips through.
Speaking of CSP, a practical tip: enforcing a strict policy right away can break legitimate scripts too and cause panic. Run it in report-only mode first; browsers won't block violations but will report them to you. Collect reports for a week or two, tune the policy to reality, then switch to enforcing mode. Then there is the question of third-party scripts: every analytics and marketing tool you add to your page is foreign code running inside your security perimeter, and a team that doesn't keep an inventory of them doesn't know what it is defending.
CSRF: making the victim's browser do the work
The logic of CSRF is even craftier, because the attacker never touches your site. If a user visits a malicious page while logged into your application, that page can make the user's browser send requests to your API. The browser automatically attaches the relevant cookies to the request, and from your server's perspective the request looks perfectly legitimate. While the user thinks they are reading a news site, a "transfer money" or "change email" request has gone out in the background.
The defense is built in layers. Setting SameSite=Lax or Strict on cookies stops them from being sent with requests triggered from other sites and breaks the backbone of the attack. Adding a server-generated CSRF token to every state-changing request (money, data, settings, whatever it is) proves that the request really came from your interface. For sensitive operations such as changing a password or confirming a transfer, asking the user for their password or second factor again limits the damage even in the worst-case scenario.

We saw the real-life face of this attack during an audit: in an admin panel, deleting a user worked through a GET request with no token. The harmless proof-of-concept page we prepared made the browser of an administrator who had left the panel open delete a test user, without the administrator clicking anything. I still remember the look on the team's faces; the distance between a "theoretical risk" and "a record deleted before your eyes" teaches more than any presentation ever could.
SameSite arrived, but tokens didn't retire
Browsers tightening their SameSite defaults has genuinely made our job easier; let's give credit where it's due. But concluding that "tokens are no longer needed" is dangerous. Old browsers live on in the field, trust relationships between subdomains open unexpected doors, and teams that forget Lax mode allows top-level GET requests leave the door ajar with their own hands by performing state-changing operations over GET. (We have seen an endpoint that deleted records via GET; a chat app that generates link previews deleted records just by displaying the link. A true story.)
No single layer of defense is enough on its own; that is the whole reason they are layers.
The reflexes we look for in code review
Immunity against these two classes of attack is less a matter of tools than of reflexes. The chain we look for in our reviews is this: is input validated on the server; is output escaped for the context it is rendered in; is there any path that writes raw data into HTML; does the CSP header lock down script sources; are SameSite, HttpOnly and Secure all set on cookies; does every state-changing endpoint have a token? In projects where the team has turned this chain into a reflex, we no longer see these two classes of vulnerability in audits.

Don't leave reflexes to human memory; automate them. Static analysis rules can flag dangerous function usage as early as the commit stage; dependency scanning catches known vulnerabilities in the packages you use within the CI pipeline; and a few harmless attack scenarios added to your end-to-end test suite sound the alarm when one of the protective layers loosens. Keeping frameworks and libraries up to date is part of this hygiene too: they carry most of the defenses for you, and staying on an old version means giving up those defenses.
A reminder for those who say, "Our product is a mobile app, we don't have a web side": almost every mobile app has an admin panel behind it, and that panel is on the web. The attacker doesn't need to bother with your customer app; why would they, when there is a panel that lets them manage everything from the inside? In our audits, the weakest link usually turns out to be that unglamorous panel people describe as "only we use it," because nobody considers it part of the product, except the attacker.
If you're not sure where your own application stands in this chain, write to us for a security review. Experiencing the two hours after "we use React" as a reader rather than as a client is always cheaper.