CURL-CVE-2020-8177

Source
https://curl.se/docs/CVE-2020-8177.html
Import Source
https://curl.se/docs/CURL-CVE-2020-8177.json
JSON Data
https://api.osv.dev/v1/vulns/CURL-CVE-2020-8177
Aliases
Published
2020-06-24T08:00:00Z
Modified
2026-05-27T02:29:36.152066Z
Summary
curl overwrite local file with -J
Details

curl can be tricked by a malicious server to overwrite a local file when using -J (--remote-header-name) and -i (--include) in the same command line.

The command line tool offers the -J option that saves a remote file using the filename present in the Content-Disposition: response header. curl then refuses to overwrite an existing local file using the same name, if one already exists in the current directory.

The -J flag is designed to save a response body, and so it does not work together with -i and there is logic that forbids it. However, the check is flawed and does not properly check for when the options are used in the reversed order: first using -J and then -i were mistakenly accepted.

The result of this mistake was that incoming HTTP headers could overwrite a local file if one existed, as the check to avoid the local file was done first when body data was received, and due to the mistake mentioned above, it could already have received and saved headers by that time.

The saved file would only get response headers added to it, as it would abort the saving when the first body byte arrives. A malicious server could however still be made to send back virtually anything as headers and curl would save them like this, until the first CRLF-CRLF sequence appears.

(Also note that -J needs to be used in combination with -O to have any effect.)

Database specific
{
    "CWE": {
        "desc": "Improper Restriction of Names for Files and Other Resources",
        "id": "CWE-641"
    },
    "www": "https://curl.se/docs/CVE-2020-8177.html",
    "issue": "https://hackerone.com/reports/887462",
    "package": "curl",
    "severity": "Medium",
    "last_affected": "7.70.0",
    "URL": "https://curl.se/docs/CVE-2020-8177.json",
    "affects": "tool",
    "award": {
        "amount": "700",
        "currency": "USD"
    }
}
References
Credits
    • sn on hackerone - FINDER
    • Daniel Stenberg - REMEDIATION_DEVELOPER

Affected packages

Git / github.com/curl/curl.git

Affected ranges

Type
SEMVER
Events
Introduced
7.20.0
Fixed
7.71.0
Type
GIT
Repo
https://github.com/curl/curl.git
Events

Affected versions

7.*
7.20.0
7.20.1
7.21.0
7.21.1
7.21.2
7.21.3
7.21.4
7.21.5
7.21.6
7.21.7
7.22.0
7.23.0
7.23.1
7.24.0
7.25.0
7.26.0
7.27.0
7.28.0
7.28.1
7.29.0
7.30.0
7.31.0
7.32.0
7.33.0
7.34.0
7.35.0
7.36.0
7.37.0
7.37.1
7.38.0
7.39.0
7.40.0
7.41.0
7.42.0
7.42.1
7.43.0
7.44.0
7.45.0
7.46.0
7.47.0
7.47.1
7.48.0
7.49.0
7.49.1
7.50.0
7.50.1
7.50.2
7.50.3
7.51.0
7.52.0
7.52.1
7.53.0
7.53.1
7.54.0
7.54.1
7.55.0
7.55.1
7.56.0
7.56.1
7.57.0
7.58.0
7.59.0
7.60.0
7.61.0
7.61.1
7.62.0
7.63.0
7.64.0
7.64.1
7.65.0
7.65.1
7.65.2
7.65.3
7.66.0
7.67.0
7.68.0
7.69.0
7.69.1
7.70.0
Other
curl-7_20_0
curl-7_20_1
curl-7_21_0
curl-7_21_1
curl-7_21_2
curl-7_21_3
curl-7_21_4
curl-7_21_5
curl-7_21_6
curl-7_21_7
curl-7_22_0
curl-7_23_0
curl-7_23_1
curl-7_24_0
curl-7_25_0
curl-7_26_0
curl-7_27_0
curl-7_28_0
curl-7_28_1
curl-7_29_0
curl-7_30_0
curl-7_31_0
curl-7_32_0
curl-7_33_0
curl-7_34_0
curl-7_35_0
curl-7_36_0
curl-7_37_0
curl-7_37_1
curl-7_38_0
curl-7_39_0
curl-7_40_0
curl-7_41_0
curl-7_42_0
curl-7_42_1
curl-7_43_0
curl-7_44_0
curl-7_45_0
curl-7_46_0
curl-7_47_0
curl-7_47_1
curl-7_48_0
curl-7_49_0
curl-7_49_1
curl-7_50_0
curl-7_50_1
curl-7_50_2
curl-7_50_3
curl-7_51_0
curl-7_52_0
curl-7_52_1
curl-7_53_0
curl-7_53_1
curl-7_54_0
curl-7_54_1
curl-7_55_0
curl-7_55_1
curl-7_56_0
curl-7_56_1
curl-7_57_0
curl-7_58_0
curl-7_59_0
curl-7_60_0
curl-7_61_0
curl-7_61_1
curl-7_62_0
curl-7_63_0
curl-7_64_0
curl-7_64_1
curl-7_65_0
curl-7_65_1
curl-7_65_2
curl-7_65_3
curl-7_66_0
curl-7_67_0
curl-7_68_0
curl-7_69_0
curl-7_69_1
curl-7_70_0

Database specific

vanir_signatures
[
    {
        "signature_version": "v1",
        "source": "https://github.com/curl/curl.git/commit/8236aba58542c5f89f1d41ca09d84579efb05e22",
        "target": {
            "function": "tool_header_cb",
            "file": "src/tool_cb_hdr.c"
        },
        "deprecated": false,
        "id": "CURL-CVE-2020-8177-677f1fb1",
        "signature_type": "Function",
        "digest": {
            "length": 3335.0,
            "function_hash": "199970256385423915349304268191894397674"
        }
    },
    {
        "signature_version": "v1",
        "source": "https://github.com/curl/curl.git/commit/8236aba58542c5f89f1d41ca09d84579efb05e22",
        "target": {
            "file": "src/tool_getparam.c"
        },
        "deprecated": false,
        "id": "CURL-CVE-2020-8177-78e9e990",
        "signature_type": "Line",
        "digest": {
            "line_hashes": [
                "116061019339859011694030532516786133574",
                "155641202549686486523332306578826527363",
                "54753136006731828942239281717552956336",
                "296887675917058167822353194754572525158"
            ],
            "threshold": 0.9
        }
    },
    {
        "signature_version": "v1",
        "source": "https://github.com/curl/curl.git/commit/8236aba58542c5f89f1d41ca09d84579efb05e22",
        "target": {
            "function": "getparameter",
            "file": "src/tool_getparam.c"
        },
        "deprecated": false,
        "id": "CURL-CVE-2020-8177-8f29f923",
        "signature_type": "Function",
        "digest": {
            "length": 31783.0,
            "function_hash": "87642312644709809976072261365791905246"
        }
    },
    {
        "signature_version": "v1",
        "source": "https://github.com/curl/curl.git/commit/8236aba58542c5f89f1d41ca09d84579efb05e22",
        "target": {
            "file": "src/tool_cb_hdr.c"
        },
        "deprecated": false,
        "id": "CURL-CVE-2020-8177-c3f5b5af",
        "signature_type": "Line",
        "digest": {
            "line_hashes": [
                "286895013182950075166036848406221992096",
                "258569945566588772279943309574002335383",
                "144869481224603182242709422539955781289",
                "171457237244487460579103396132147242887",
                "181764972928126467942388788163277184098",
                "302582013856799800588882298155846086554",
                "253342496056378788837245308668091297961",
                "16002101938793129165035374609937209526",
                "99101775968245942737359604662129034056",
                "192747156636641410260783562613088801957",
                "328067430002779520667223709354835284959",
                "237811893285258051715718461651790731472",
                "200681367666233024858196283918491781531",
                "195936311419697770975512179058665319611",
                "256181439150538530857768469767924111447",
                "310470984239033218120322628448619903429",
                "102392186469260102880336934299407503716",
                "168512603647264694324216763505547948095",
                "276853035220816728622143078021047923484"
            ],
            "threshold": 0.9
        }
    }
]
vanir_signatures_modified
"2026-05-27T02:29:36Z"
source
"https://curl.se/docs/CURL-CVE-2020-8177.json"