Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: enforce Content-Type to accept only binary responses
Add validation for CLI downloads that ensures the Content-Type header
is indicating a binary stream (`application/octet-stream`),
including common variants with parameters. This prevents saving unexpected
HTML or other non-binary responses (e.g., from frontend dev servers on :8080)
as binaries, improving reliability and providing clearer error feedback.
  • Loading branch information
fioan89 committed Aug 12, 2025
commit c412c977a44d2f7e962ad9b364d9ea9bb688b26b
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Changed

- content-type is now enforced when downloading the CLI to accept only binary responses

## 0.6.1 - 2025-08-11

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ class CoderDownloadService(

return when (response.code()) {
HTTP_OK -> {
val contentType = response.headers()["Content-Type"]?.lowercase()
if (contentType?.startsWith("application/octet-stream") != true) {
throw ResponseException(
"Invalid content type '$contentType' when downloading CLI from $remoteBinaryURL. Expected application/octet-stream.",
response.code()
)
}
context.logger.info("Downloading binary to temporary $cliTempDst")
response.saveToDisk(cliTempDst, showTextProgress, buildVersion)?.makeExecutable()
DownloadResult.Downloaded(remoteBinaryURL, cliTempDst)
Expand Down
Loading