Skip to content

Add "fail secure" mode and client timeout#119

Closed
timonorawski wants to merge 5 commits intowillnorris:masterfrom
timonorawski:master
Closed

Add "fail secure" mode and client timeout#119
timonorawski wants to merge 5 commits intowillnorris:masterfrom
timonorawski:master

Conversation

@timonorawski
Copy link
Copy Markdown

  • Adds a -failsecure command line parameter that ensures that the target content is always verified to in fact be an image before returning it to the requester - existing functionality acts as an open http proxy with potential for abuse. Note: added this as a command line option so as not to break existing use cases that may depend on the open proxy logic (i.e. using imageproxy as a backend cache for non-image files).
    examples:

  • http://localhost:8080/600x/https://www.google.com

  • http://localhost:8080/https://www.cnn.com

  • applies the Timeout parameter to the http client as well as the server, so as not to leave open connections potentially consuming system resources after we have given up requesting from a slow upstream server.
    e.g. run a nonresponsive http server and then try to imageproxy it

  • http://localhost:8080/200x/http://localhost:10000/test.jpg

unresponsivevserver.go:
package main
import (
"net/http"
"time"
"log"
)
func main() {
svr := &http.Server{
Addr:":10000",
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
time.Sleep(time.Hour)
}),
}
log.Fatal(svr.ListenAndServe())
}

…tream servers are nonresponsive

Add Fail Secure mode switchable via --secure -- which will prevent
accidental proxying of remote targets that are not images.
…t inside the Transform.

Preserve previous functionality of just returning the target data if the
FailSecure flag is not set.
Transform: If FailSecure is set and no transform is specified, test
whether the image is parseable before returning its raw bytes.
@willnorris
Copy link
Copy Markdown
Owner

I'm fairly certain this is addressed by the content-type checking added in 39a4e18 and 0370572. Passing -contentTypes "image/*" should prevent non-image resources from being served.

If there's still more to be done here, please continue the discussion, or re-open the issue.

@willnorris willnorris closed this Mar 17, 2019
j-mcnally pushed a commit to Chowly/imageproxy that referenced this pull request Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants