Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
CVE-2018-18925 — Exploit for CVE-2018-18925: Remote Code Execution in Gogs via directory traversal in session handling, enabling session bypass and administrator access with subsequent RCE through git hooks. | Kitploit
Tools/GitHubGitHub/j4k0m/cve-2018-18925
Vulnerability AnalysisExploitationWeb Application ExploitationPenetration TestingRemote Access ToolPayload Development
GitHubj4k0m/cve-2018-18925

CVE-2018-18925

Exploit for CVE-2018-18925: Remote Code Execution in Gogs via directory traversal in session handling, enabling session bypass and administrator access with subsequent RCE through git hooks.

View Repository
7234 years agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

CVE-2018-18925

Exploitation of CVE-2018-18925 a Remote Code Execution against the Git self hosted tool: Gogs.

Gogs is based on the Macaron framework. The system used to manage session is very similar to what PHP does. The session identifier in the cookie is mapped to a file on the file system. When the web server receives a request with a session identifier (as a cookie), it looks up for the file on the file system.

The vulnerability is a simple directory traversal when retrieving the file used for the session on the file system. You can for example, set the i_like_gogits cookie to ../../../../../../etc/passwd to get an error from the server.

image

Exploitation:

In order to exploit the session bypass, we will need a way to upload a specially crafted file, then we will use this file as our session id, we can create our own crafted session id file with https://github.com/RyouYoo/CVE-2018-18925/blob/main/main.go.

Usage:

root@kitploit:~
go run main.go

Uploading the malicious file and logged in as administrator

When creating the copy of the repository locally, Gogs put the files in /data/gogs/data/tmp/local-repo/[REPO_ID]/[FILENAME] (this repository is only created when you use the "Upload file" functionality).

image

Where [FILENAME] is the name of the file you upload and [REPO_ID] is the repository identifier that can be found using the Fork link:

image

Where 5 is the repo id.

By default, the sessions are stored in /data/gogs/data/sessions/. Therefore, you can use the following relative path for your session id: ../tmp/local-repo/[REPO_ID]/[FILENAME]. By using this path in your i_like_gogits cookie, you should be logged in as administrator.

133289399-47f6692b-7cfa-443d-89d3-caa5b9828250

Remote Code Execution:

In order to get RCE, you can use the git hooks functionality in a given repository to run a shell script.

image

In pre-receive inject your code:

image

Then make a push request, with git or with create file function to get the hook executed.

Download Tool