Skip to content

Commit e213dba

Browse files
committed
security fix
1 parent 25ad31b commit e213dba

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

HISTORY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ The codebase for Dependency Injection, Internationalization and localization and
2828

2929
## Fixes and Improvements
3030

31+
- Push a security fix reported by [Kirill Efimov](https://github.com/kirill89) for older go runtimes.
32+
3133
- New `Configuration.Timeout` and `Configuration.TimeoutMessage` fields. Use it to set HTTP timeouts. Note that your http server's (`Application.ConfigureHost`) Read/Write timeouts should be a bit higher than the `Configuration.Timeout` in order to give some time to http timeout handler to kick in and be able to send the `Configuration.TimeoutMessage` properly.
3234

3335
- New `apps.OnApplicationRegistered` method which listens on new Iris applications hosted under the same binary. Use it on your `init` functions to configure Iris applications by any spot in your project's files.

context/context.go

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,13 +2032,7 @@ func (ctx *Context) FormFiles(key string, before ...func(*Context, *multipart.Fi
20322032

20332033
innerLoop:
20342034
for _, header := range fhs[key] {
2035-
// Fix an issue that net/http has,
2036-
// an attacker can push a filename
2037-
// which could lead to override existing system files
2038-
// by ../../$header.
2039-
// Reported by Frank through security reports.
2040-
header.Filename = strings.ReplaceAll(header.Filename, "../", "")
2041-
header.Filename = strings.ReplaceAll(header.Filename, "..\\", "")
2035+
header.Filename = filepath.Base(header.Filename)
20422036

20432037
for _, b := range before {
20442038
if !b(ctx, header) {
@@ -2100,13 +2094,9 @@ func (ctx *Context) UploadFormFiles(destDirectory string, before ...func(*Contex
21002094
for _, files := range fhs {
21012095
innerLoop:
21022096
for _, file := range files {
2103-
// Fix an issue that net/http has,
2104-
// an attacker can push a filename
2105-
// which could lead to override existing system files
2106-
// by ../../$file.
2107-
// Reported by Frank through security reports.
2108-
file.Filename = strings.ReplaceAll(file.Filename, "../", "")
2109-
file.Filename = strings.ReplaceAll(file.Filename, "..\\", "")
2097+
// Security fix for go < 1.17.5:
2098+
// Reported by Kirill Efimov (snyk.io) through security reports.
2099+
file.Filename = filepath.Base(file.Filename)
21102100

21112101
for _, b := range before {
21122102
if !b(ctx, file) {

0 commit comments

Comments
 (0)