Let's suppose that attacker was able to inject JavaScript into website. Obviously he can do any HTTP request to backend mimicking user actions, unless there's some confirmation like SMS code which required direct interaction from user (even in this case malicious JavaScript could fool user). So, I guess, this attack vector couldn't be reasonably defended. But if attacker steals session, he can impersonate user and do almost anything. So I'm thinking about defense of this vector. Sure, server could check IP address, etc, but it's not always possible.
First thing: storing session in an HTTP-only cookie. JavaScript can't steal it. So far so good. But there's another weakness: 3-rd party website can craft form tag with action from my server and submit this form with user cookie. One could use CSRF tokens, but again they should be available to JavaScript, they could be stolen if JavaScript is compromised, they must be maintained on the webserver, which hurts scalability, etc. I'm thinking about using PUT method for every REST action (well, it won't be a proper REST obviously, let's call it HTTP API). There's no way to trick user into issuing PUT request from 3-rd party website and HTTP-only cookie will prevent stealing of cookie value.
I'm not seeing this usage, so I guess I'm missing something and there should be simpler way to secure endpoints?