Summery
Gitea is a self-hosted Git service, similar to GitHub. It lets users host source-code repositories, manage changes, collaborate on projects, and use an API to automate those actions. Its web interface commonly uses port 3000.
API
Besides normal GUI access, gitea also has a comprehensive api endpoint infrastructure which allows you to do all the things you could’ve done with GUI and more with HTTP requests.
Sometimes you may not have credentials to access the GUI, but you may find a user token which will let you access the corresponding API endpoints.
At the core of the Gitea API there is Swagger which is a set of tools for describing and exploring an API.
Swagger UI provides an interactive page listing API endpoints, their HTTP methods, parameters, expected responses, and authentication requirements. The underlying API description uses the OpenAPI specification.
To access the API, you need a user token, and to properly authenticate with it, there are a few ways to do it:
- You can append the token as a GET parameter with
?token=43ce39bb0bd6bc489284f2905f033ca467a6362f - You can add it to the HTTP request, like in BurpSuite with
Authorization: token 43ce39bb0bd6bc489284f2905f033ca467a6362f
There are also a few more ways to do it described here.
Endpoints
Gitea has a big numbers of endpoints which you can enumerate. Below I list the ones I found to be generally useful:
/api/v1/users/search - Enumerate all users
/api/v1/repos/search - Enumerate all repositories
/api/v1/repos/ellen.freeman/website/commits - Overview of all commits, also hold the commit names in the sha value. You can gather all commits that way
/api/v1/repos/ellen.freeman/website/git/commits/73cdcc185726ea3ae5687a04a3c97fab1ae1714a.diff - Read defails of what was changed in a given commit
/api/v1/repos/ellen.freeman/website/contents - List all files in a repository
/api/v1/repos/ellen.freeman/website/contents/readme.md - Read a specific file
Cookies
Gitea also has some cookies which might be used for privilege escalation in specific scenerios:
_csrf - CSRF protection token. Helps verify that requests changing data are legitimate
i_like_gitea - Session cookie used to identify the logged-in session, theft of it may allow account impersonation.
redirect_to - Stores the URL to visit after an action such as logging in