Has CORS support in Git endpoints been considered? #188403
Replies: 2 comments 1 reply
-
|
The lack of CORS support on Git endpoints is generally intentional and tied to security considerations. Allowing arbitrary browser clients to directly access Git operations could create several issues: exposure of authentication tokens in browser contexts increased attack surface for malicious scripts difficulty enforcing proper permission boundaries potential abuse scenarios from untrusted origins Because of this, many applications that need browser-based Git operations typically rely on an intermediate backend service. A common architecture looks like: Browser client → application backend → GitHub API / Git endpoints In this model the backend service: handles authentication securely proxies Git operations enforces rate limits and permissions protects secrets from being exposed in the browser While it may feel like additional complexity, this pattern is widely used for security reasons and helps prevent leaking credentials or enabling unwanted automated Git interactions directly from browser contexts. If the goal is a browser-first Git experience, some alternatives that developers typically explore are: using a lightweight proxy service running a small serverless function as a secure intermediary relying on GitHub REST/GraphQL APIs instead of raw Git endpoints when possible In short, the proxy requirement is not just a limitation but largely a deliberate security design choice. |
Beta Was this translation helpful? Give feedback.
-
|
Right now the lack of CORS support on Git endpoints is generally intentional and by design due to security reasons. Allowing arbitrary browser clients to directly hit Git endpoints with CORS would expose authentication tokens in browser contexts, increase the attack surface for malicious scripts, and make it harder to enforce permission boundaries and rate limits. That’s why most browser-based Git workflows don’t connect directly to Git protocol endpoints, and instead rely on an intermediate backend to securely handle authentication and proxy requests. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Product Feedback
Body
I am working on an app which works in the desktop and the browser to allow users to check out a repository, make changes, and check them back in as you expect.
To make it work in the browser I have been using the excellent isomorphic-git library. However I have encountered one area of architectural and security concern.
Because of CSP/CORS configuration in the Git endpoints, similar projects have had to proxy the requests, which involves giving deep access to a third party. I don't think most users realise the risk this poses. Any CORS proxy has complete access to the HTTP request without any of the protections afforded by HTTPS.
I can make this software a desktop app and sidestep this, or I can put my users at risk (and pay for the bandwidth of routing their request to some other service and add another dependency to my architecture), but if there's a first party solution to this problem I would be extremely keen to adopt it.
I completely understand if this has been discussed before (I can't find it if it's public), I would love to know if it's a) rejected b) in the pipeline or c) not been considered before.
Thanks for the great service.
Related:
https://github.com/orgs/community/discussions/49980
https://github.com/gr2m/github-api-wishlist/tree/master/wishlist/cors-for-adjacent-domains
sorry this was originally posted as "Product Feedback" but has to re-post it. is there a way to relabel this?
Beta Was this translation helpful? Give feedback.
All reactions