Skip to content

Commit bf6cbd0

Browse files
committed
enforce ascii hostname format
1 parent d876300 commit bf6cbd0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/api/internal/handlers/sandbox_create.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,20 @@ func (a *APIStore) PostSandboxes(c *gin.Context) {
173173
return
174174
}
175175

176-
_, err = idna.Display.ToUnicode(hostname)
176+
host, err := idna.Display.ToASCII(hostname)
177177
if err != nil {
178178
telemetry.ReportError(ctx, "error when parsing mask request host", err, telemetry.WithSandboxID(sandboxID))
179179
a.sendAPIStoreError(c, http.StatusBadRequest, fmt.Sprintf("Invalid mask request host: %s", err))
180180

181181
return
182182
}
183+
184+
if !strings.EqualFold(host, hostname) {
185+
telemetry.ReportError(ctx, "mask request host is not ASCII", nil, telemetry.WithSandboxID(sandboxID), attribute.String("mask_request_host", hostname), attribute.String("mask_request_host_ascii", host))
186+
a.sendAPIStoreError(c, http.StatusBadRequest, fmt.Sprintf("Mask request host '%s' is not ASCII. Please use ASCII characters only.", hostname))
187+
188+
return
189+
}
183190
}
184191

185192
network = &types.SandboxNetworkConfig{

0 commit comments

Comments
 (0)