Skip to content

Commit

Permalink
Ensure that we don't have a vulnerability from cabal (#737)
Browse files Browse the repository at this point in the history
* Ensure that we don't have a vulnerability from cabal

This makes sure we don't get a homepage URL from cabal that's too
long and causes a performance issue leading to a denial of service.

Fixes https://github.com/github/licensed/security/code-scanning/1
  • Loading branch information
dangoor authored Aug 13, 2024
1 parent ce7794f commit d433668
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Changed

- Ensure homepage string is not too long in cabal.rb to avoid DOS attack

## 4.5.0

### Changed
Expand Down
6 changes: 6 additions & 0 deletions lib/licensed/sources/cabal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ def package_docs_dirs(package)
# Returns a homepage url that enforces https and removes url fragments
def safe_homepage(homepage)
return unless homepage
# Ensure there's no denial of service issue with a long homepage
# 1000 characters is likely enough for any real project homepage
# See https://github.com/github/licensed/security/code-scanning/1
if homepage.length > 1000
raise ArgumentError, "Input too long"
end
# use https and remove url fragment
homepage.gsub(/http:/, "https:")
.gsub(/#[^?]*\z/, "")
Expand Down

0 comments on commit d433668

Please sign in to comment.