Log Forging Issue with Autocomplete::ProjectFinder
The Autocomplete::ProjectFinder in GitLab raised an exception that included the user-supplied project_id without sanitisation, allowing an attacker to inject newline characters and forge arbitrary log entries. An attacker could mislead audit and security operations by creating fake log lines.
GitLab
Originally disclosed on GitLab
- Fixed in 3 months
- Disclosed after 3 months
HackerOne report #786030 by hackingmommies on 2020-01-30, assigned to @cmaxim:
Summary
A vulnerability exists in Autocomplete::ProjectFinder exploiting which an attacker will be able to inject arbitrary log entries for the gitlab-rails web application.
The issue exists in app/finders/autocomplete/project_finder.rb in the following code segment
def execute
[...]
unless Ability.allowed?(current_user, :read_project, project)
raise ActiveRecord::RecordNotFound
.new("Could not find a Project with ID #{project_id}")
end
[...]
end
The ActiveRecord::RecordNotFound exception is raised with user supplied string in project_id, which is logged as is. An attacker can supply specially crafted values, especially with \r\n characters to forge arbitrary log entries.
Steps to reproduce
Follow an URL such as below
http://192.168.56.30/autocomplete/users?project_id=x%0D%0A%0D%0ATHIS%20IS%20A%20INJECTED%20LOG%20ENTRY%0D%0A%0D%0A
Observe injected log entry in production.log
Processing by AutocompleteController#users as HTML
Parameters: {"project_id"=>"x\r\n\r\nTHIS IS A INJECTED LOG ENTRY\r\n\r\n"}
ActiveRecord::RecordNotFound (Couldn't find Project with 'id'=x
THIS IS A INJECTED LOG ENTRY
):
app/finders/autocomplete/project_finder.rb:23:in `execute'
app/controllers/autocomplete_controller.rb:9:in `users'
ee/lib/gitlab/ip_address_state.rb:10:in `with'
For Gitlab-CE, the path will be:
/opt/gitlab/embedded/service/gitlab-rails/log/production.log
Fix
The issue can be addressed with a simple patch such as below
--- a/app/finders/autocomplete/project_finder.rb
+++ b/app/finders/autocomplete/project_finder.rb
@@ -13,7 +13,7 @@ module Autocomplete
# * project_id: The ID of the project to find.
def initialize(current_user = nil, params = {})
[@]current_user = current_user
- [@]project_id = params[:project_id]
+ [@]project_id = params[:project_id].to_i
end
Impact
An attacker may be able to forge log entries thus misguiding audit and secops activities.
Impact
An attacker may be able to forge log entries thus misguiding audit and secops activities.
Attachments
Warning: Attachments received through HackerOne, please exercise caution!
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
An attacker may be able to forge log entries thus misguiding audit and secops activities.
What the attacker needed
Access to the GitLab instance
The fix
The issue can be addressed by converting the project_id parameter to an integer before use, as shown in the patch.
How it was found
- Send a request to the autocomplete users endpoint with a crafted project_id containing newline characters.
- Observe the injected log entry in the production.log file.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a web application logs an error, it sometimes includes user input. If that input contains newline characters, an attacker can make the log show fake entries. This can confuse anyone reviewing the logs, such as auditors or security teams.
What is Misconfiguration?
Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.