> It is essentially security by obscurity and protects nothing.
What.
I think there's been a fundamental misunderstanding of who is being protected here on your part, and what CORS is actually for.
It's your run-of-the-mill user that CORS protects, and CORS being enforced protects them when they visit e.g. an attacker-controlled site with, for example, a valid cookie-based session on your service. It prevents the attacker's site from making dangerous authenticated requests to your API service and reading the result.
> If someone is really determined they will either 1) turn off CORS with a browser extension 2) simply call your precious API from something other than an a browser
That's not what CORS is designed to protect against at all, of course you can hit an API separately and your HTTP client will ignore the CORS headers. Your HTTP client isn't a browser! It doesn't need to worry about CORS.
Similarly, users shooting themselves in the foot by disabling CORS are only hurting themselves. They are not the attacker here.
Not understanding CORS and making a comment like this is taking that ignorance to a new level though. Please read up on what you're talking about.
It's not security for the provider of the API, it's security for the user of a web browser
But no, it's not really a great idea to make every single privileged API in the world completely insecure just so the admins of public APIs can avoid adding a wildcard header to their servers.
It definitely protects more than nothing :)
Also, I know quite a few public sites that serve debugging data if the request comes from the company's IP range. They shouldn't be doing this, but they do.
Maybe one day we can remove CORS for no-credential requests if we can detect that the destination isn't "internal", and we just decide that folks who serve debugging data by IP deserve to have their data leak. I've heard ideas around this for 10 years now, but maybe it'll happen eventually.
No, it isn't security through obscurity. Yes, it protects and it protects a lot.
Thank you for contributing to lack of knowledge, do keep up.
It is essentially security by obscurity and protects nothing. Don't get me started how some technologies like AWS Lambda with a Gateway, when a function has an error, responds by default in such a way it makes the browser log a CORS error instead of, you know, a 500 or the actual error message.
I always do the "allow anything" setting for CORS when I make an API.