dataall icon indicating copy to clipboard operation
dataall copied to clipboard

Remove wildcard from Access-Control-Allow-Origin header

Open zsaltys opened this issue 1 year ago • 9 comments

Currently all graphql endpoints respond with header: Access-Control-Allow-Origin: *. This allows to make calls from other origins outside data.all domain. In reality this is very low or non existent security risk as * prevents passing credentials with cookies so it would be impossible to see anything sensitive unless a request was being made to something that is not protected by authentication. However our security team is still flagging this up and it should be a simple fix and probably a good practice to fix.

These are current places where this header is mentioned: https://github.com/search?q=repo%3Adata-dot-all%2Fdataall%20Access-Control-Allow-Origin&type=code

zsaltys avatar Jan 25 '24 14:01 zsaltys

Thanks for opening this issue - should be a good security enhancement that we can look to pick up sometime after our v2.3 release

noah-paige avatar Jan 31 '24 01:01 noah-paige

@mourya-33 maybe something you could pick up?

zsaltys avatar Mar 15 '24 15:03 zsaltys

Hi @zsaltys @mourya-33 - it may prove challenging to implement the above with the ongoing development of dataall programmatic tools, including the CLI and SDK initiatives

With the above in mind - the origin of the API request to the api endpoint and associated back-end resources is not limited to a single domain / client origin

I also want to note that we protect the Cloudfront Domain, API GW endpoint, and Cognito User Pool (if applicable) with WAF rules to protect against common threats and known bad actors by default

noah-paige avatar Jun 11 '24 16:06 noah-paige

@noah-paige I don't think SDK initiatives would care what the header of this value is only browsers should.. Also the SDK should always send the same origin the one we provide in the redirect. This also solves the issue of having origin filter on WAF for the api gateway.

zsaltys avatar Jun 17 '24 13:06 zsaltys

Hi @zsaltys - for requests that would originate from SDK/CLI, I would be hesitant from enforcing a particular custom Origin header as it (1) is not the true origin of the request, (2) could open some additional security implications, (3) adds additional complexity and restrictions to the requests made from CLI/SDK, and (4) is best practice to omit this Origin header for non-browser requests.

That being said - if we want to pick up the following security enhancement I believe we can still do as follows to better our security posture:

  • [1] Have a configurable way of restricting Access-Control-Allow-Origin to dataall domain
    • Or maybe can have some more intelligent way of restricting allowable origins to dataall domain only if Origin header is present (to note - the origin header is automatically added and cannot be modified programmatically via the browser (link))
  • [2] For the client making requests from SDK/CLI have a general purpose way of setting custom headers that are particular for a individual's use case

cc: @petrkalos @anmolsgandhi @mourya-33

noah-paige avatar Jun 17 '24 17:06 noah-paige

@noah-paige this would work us to make it configurable.. Then we put in our Access-Control-Allow-Origin the origin we expect... And in SDK we have to specify the origin as well because our WAF checks that the origin is set. So let's go with this approach and make the Access-Control-Allow-Origin configurable and it can be * by default.

zsaltys avatar Jun 18 '24 10:06 zsaltys

@anmolsgandhi @mourya-33 it would really be very good to have this at least merged and ideally released before Sept 1st.

zsaltys avatar Jun 21 '24 10:06 zsaltys

@zsaltys Noted and it does align with the potential timeline in my mind as well. @noah-paige can you work with @mourya-33 based on the recommendation you provided and prioritize it?

anmolsgandhi avatar Jun 21 '24 12:06 anmolsgandhi

@mourya-33 - would you have the bandwidth to pick up this enhancement for our next release v2.7? I can help work together for any review required as well

cc: @anmolsgandhi

noah-paige avatar Jul 09 '24 16:07 noah-paige

I am on this already @noah-paige . Making this part of cdk.json as a configuration which defaults to *

mourya-33 avatar Aug 08 '24 22:08 mourya-33