Skip to content

Commit f7a14d9

Browse files
committed
TUN-6728: Verify http status code ingress rule
1 parent 902e5be commit f7a14d9

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2022.9.0
2+
### New Features
3+
- cloudflared now rejects ingress rules with invalid http status codes for http_status.
4+
15
## 2022.8.1
26
### New Features
37
- cloudflared now remembers if it connected to a certain protocol successfully. If it did, it does not fall back to a lower

ingress/ingress.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,14 @@ func validateIngress(ingress []config.UnvalidatedIngressRule, defaults OriginReq
182182
path := strings.TrimPrefix(r.Service, prefix)
183183
service = &unixSocketPath{path: path, scheme: "https"}
184184
} else if prefix := "http_status:"; strings.HasPrefix(r.Service, prefix) {
185-
status, err := strconv.Atoi(strings.TrimPrefix(r.Service, prefix))
185+
statusCode, err := strconv.Atoi(strings.TrimPrefix(r.Service, prefix))
186186
if err != nil {
187-
return Ingress{}, errors.Wrap(err, "invalid HTTP status")
187+
return Ingress{}, errors.Wrap(err, "invalid HTTP status code")
188188
}
189-
srv := newStatusCode(status)
189+
if statusCode < 100 || statusCode > 999 {
190+
return Ingress{}, fmt.Errorf("invalid HTTP status code: %d", statusCode)
191+
}
192+
srv := newStatusCode(statusCode)
190193
service = &srv
191194
} else if r.Service == HelloWorldService || r.Service == "hello-world" || r.Service == "helloworld" {
192195
service = new(helloWorld)

ingress/ingress_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,14 @@ ingress:
208208
args: args{rawYAML: `
209209
ingress:
210210
- service: http_status:asdf
211+
`},
212+
wantErr: true,
213+
},
214+
{
215+
name: "Invalid HTTP status code",
216+
args: args{rawYAML: `
217+
ingress:
218+
- service: http_status:8080
211219
`},
212220
wantErr: true,
213221
},

0 commit comments

Comments
 (0)