Skip to content

Commit

Permalink
Fix Malformed dir traversal (#331)
Browse files Browse the repository at this point in the history
* Directory traversal with malformed HTTP request

#330

* bump version

* also %2e

* Use prefix to check invalid Path

---------

Co-authored-by: n0vad3v <[email protected]>
  • Loading branch information
BennyThink and n0vad3v authored Apr 23, 2024
1 parent c7bebfc commit be32328
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var (
ProxyMode bool
Prefetch bool
Config = NewWebPConfig()
Version = "0.11.2"
Version = "0.11.3"
WriteLock = cache.New(5*time.Minute, 10*time.Minute)
ConvertLock = cache.New(5*time.Minute, 10*time.Minute)
RemoteRaw = "./remote-raw"
Expand Down
6 changes: 6 additions & 0 deletions handler/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ func Convert(c *fiber.Ctx) error {
// 2. generate rawImagePath, could be local path or remote url(possible with query string)
// 3. pass it to encoder, get the result, send it back

// normal http request will start with /
if !strings.HasPrefix(c.Path(), "/") {
_ = c.SendStatus(http.StatusBadRequest)
return nil
}

var (
reqHostname = c.Hostname()
reqHost = c.Protocol() + "://" + reqHostname // http://www.example.com:8000
Expand Down

0 comments on commit be32328

Please sign in to comment.