In this case, since the attacker has access to the source code, they could easily disable a site's Content Security Policy.
Plus, I should have pointed out that CSP can be applied at higher layers, including nginx itself or a WAF, that the attacker may not be able to access or modify. I didn't think of it at the time.