Skip to content

[security] CRLF Injection hardening #1963

@prabhu

Description

@prabhu

Some headers such as apiKey are passed as-is to the http client library got. got has some checks for CRLF Injection and Response Splitting payloads. However, it will be nice to sanitize and harden the headers before use.

chen queries

atom.tag.name("http-client").call.argument.df(atom.method("parseQueryString").parameter).t
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Location                                                     ┃ Method                                    ┃ Parameter                                                                                                ┃ Tracked                                                                                         ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ lib/server/server.js#140                                     │ parseQueryString                          │ options                                                                                                  │ lib/server/server.js::program:parseQueryString                                                  │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/server/server.js#156                                     │ parseQueryString                          │                                                                                                          │ return options                                                                                  │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/server/server.js#247                                     │ anonymous1                                │ parseQueryString(                                                                                        │ lib/server/server.js::program:parseQueryString                                                  │
│                                                              │ Tags: framework-input                     │         q,                                                                                               │                                                                                                 │
│                                                              │                                           │         req.body,                                                                                        │                                                                                                 │
│                                                              │                                           │         Object.assign(Object.create(null), options),                                                     │                                                                                                 │
│                                                              │                                           │       )                                                                                                  │                                                                                                 │
├──────────────────────────────────────────────────────────────┼───────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ lib/server/server.js#78                                      │ gitClone                                  │ branch                                                                                                   │ lib/server/server.js::program:gitClone                                                          │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/server/server.js#312                                     │ anonymous1                                │ reqOptions                                                                                               │ createBom(srcDir, reqOptions)                                                                   │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/cli/index.js#8060                                        │ createBom                                 │ options                                                                                                  │ lib/cli/index.js::program:createBom                                                             │
│                                                              │ Tags: exported                            │                                                                                                          │                                                                                                 │
│ lib/server/server.js#313                                     │ anonymous1                                │ reqOptions                                                                                               │ postProcess(bomNSData, reqOptions)                                                              │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/stages/postgen/postgen.js#52                             │ postProcess                               │ options                                                                                                  │ lib/stages/postgen/postgen.js::program:postProcess                                              │
│                                                              │ Tags: exported                            │                                                                                                          │                                                                                                 │
│ lib/stages/postgen/postgen.js#61                             │ postProcess                               │ options                                                                                                  │ filterBom(jsonPayload, options)                                                                 │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/stages/postgen/postgen.js#302                            │ filterBom                                 │ options                                                                                                  │ lib/stages/postgen/postgen.js::program:filterBom                                                │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/stages/postgen/postgen.js#357                            │ filterBom                                 │ comp                                                                                                     │ newPkgMap[comp["bom-ref"]] = comp                                                               │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/stages/postgen/postgen.js#401                            │ filterBom                                 │ newPkgMap                                                                                                │ Object.keys(newPkgMap)                                                                          │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/stages/postgen/postgen.js#427                            │ filterBom                                 │ newcomponents                                                                                            │ bomJson.components = newcomponents                                                              │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/stages/postgen/postgen.js#464                            │ filterBom                                 │                                                                                                          │ return bomJson                                                                                  │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/stages/postgen/postgen.js#61                             │ postProcess                               │ filterBom(jsonPayload, options)                                                                          │ lib/stages/postgen/postgen.js::program:filterBom                                                │
│                                                              │                                           │                                                                                                          │                                                                                                 │
├──────────────────────────────────────────────────────────────┼───────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ lib/stages/postgen/postgen.js#197                            │ applyStandards                            │ bomJson                                                                                                  │ lib/stages/postgen/postgen.js::program:applyStandards                                           │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/stages/postgen/postgen.js#227                            │ applyStandards                            │                                                                                                          │ return bomJson                                                                                  │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/stages/postgen/postgen.js#62                             │ postProcess                               │ applyStandards(bomNSData.bomJson, options)                                                               │ lib/stages/postgen/postgen.js::program:applyStandards                                           │
│                                                              │                                           │                                                                                                          │                                                                                                 │
├──────────────────────────────────────────────────────────────┼───────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ lib/stages/postgen/postgen.js#81                             │ applyMetadata                             │ bomJson                                                                                                  │ lib/stages/postgen/postgen.js::program:applyMetadata                                            │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/stages/postgen/postgen.js#186                            │ applyMetadata                             │                                                                                                          │ return bomJson                                                                                  │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/stages/postgen/postgen.js#63                             │ postProcess                               │ applyMetadata(bomNSData.bomJson, options)                                                                │ lib/stages/postgen/postgen.js::program:applyMetadata                                            │
│                                                              │                                           │                                                                                                          │                                                                                                 │
├──────────────────────────────────────────────────────────────┼───────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ lib/stages/postgen/postgen.js#494                            │ annotate                                  │ bomJson                                                                                                  │ lib/stages/postgen/postgen.js::program:annotate                                                 │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/stages/postgen/postgen.js#528                            │ annotate                                  │ bomAnnotations                                                                                           │ bomAnnotations.push({                                                                           │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/stages/postgen/postgen.js#538                            │ annotate                                  │ bomAnnotations                                                                                           │ bomJson.annotations = bomAnnotations                                                            │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/stages/postgen/postgen.js#562                            │ annotate                                  │ bomJson                                                                                                  │ bomJson.serialNumber                                                                            │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/stages/postgen/postgen.js#597                            │ annotate                                  │ bomJson                                                                                                  │ bomJson.serialNumber                                                                            │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/stages/postgen/postgen.js#601                            │ annotate                                  │ bomJson                                                                                                  │ bomJson.serialNumber                                                                            │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/stages/postgen/postgen.js#612                            │ annotate                                  │                                                                                                          │ return bomJson                                                                                  │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/stages/postgen/postgen.js#66                             │ postProcess                               │ annotate(bomNSData.bomJson, options)                                                                     │ lib/stages/postgen/postgen.js::program:annotate                                                 │
│                                                              │                                           │                                                                                                          │                                                                                                 │
├──────────────────────────────────────────────────────────────┼───────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ lib/stages/postgen/postgen.js#70                             │ postProcess                               │                                                                                                          │ return bomNSData                                                                                │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/server/server.js#313                                     │ anonymous1                                │ postProcess(bomNSData, reqOptions)                                                                       │ lib/stages/postgen/postgen.js::program:postProcess                                              │
│                                                              │                                           │                                                                                                          │                                                                                                 │
├──────────────────────────────────────────────────────────────┼───────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ lib/cli/index.js#8334                                        │ submitBom                                 │ bomContents                                                                                              │ lib/cli/index.js::program:submitBom                                                             │
│                                                              │ Tags: exported                            │                                                                                                          │                                                                                                 │
│ lib/cli/index.js#8336                                        │ submitBom                                 │ bomContents                                                                                              │ JSON.stringify(bomContents)                                                                     │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/cli/index.js#8336                                        │ submitBom                                 │ JSON.stringify(bomContents)                                                                              │ JSON.stringify ⤴                                                                                │
│                                                              │                                           │                                                                                                          │                                                                                                 │
├──────────────────────────────────────────────────────────────┼───────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ lib/cli/index.js#8336                                        │ submitBom                                 │ Buffer.from(JSON.stringify(bomContents))                                                                 │ Buffer.from ⤴                                                                                   │
│                                                              │                                           │                                                                                                          │                                                                                                 │
├──────────────────────────────────────────────────────────────┼───────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ lib/cli/index.js#8336                                        │ submitBom                                 │ Buffer.from(JSON.stringify(bomContents)).toString(                                                       │ Buffer.from:<returnValue>:toString ⤴                                                            │
│                                                              │                                           │     "base64",                                                                                            │                                                                                                 │
│                                                              │                                           │   )                                                                                                      │                                                                                                 │
├──────────────────────────────────────────────────────────────┼───────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ lib/cli/index.js#8339                                        │ submitBom                                 │ encodedBomContents                                                                                       │ encodedBomContents.startsWith("77u/")                                                           │
│                                                              │ Tags: framework-output                    │                                                                                                          │                                                                                                 │
│ lib/cli/index.js#8340                                        │ submitBom                                 │ encodedBomContents                                                                                       │ encodedBomContents.substring(4)                                                                 │
│                                                              │ Tags: framework-output                    │                                                                                                          │                                                                                                 │
│ lib/cli/index.js#8340                                        │ submitBom                                 │ encodedBomContents.substring(4)                                                                          │ __ecma.String:substring ⤴                                                                       │
│                                                              │ Tags: framework-output                    │                                                                                                          │                                                                                                 │
├──────────────────────────────────────────────────────────────┼───────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ lib/cli/index.js#8344                                        │ submitBom                                 │ encodedBomContents                                                                                       │ _tmp_769.bom = encodedBomContents                                                               │
│                                                              │ Tags: framework-output                    │                                                                                                          │                                                                                                 │
│ lib/cli/index.js#8342                                        │ submitBom                                 │                                                                                                          │ _tmp_769                                                                                        │
│                                                              │ Tags: exported                            │                                                                                                          │                                                                                                 │
│ lib/cli/index.js#8426                                        │ submitBom                                 │ bomPayload                                                                                               │ _tmp_775.json = bomPayload                                                                      │
│                                                              │                                           │                                                                                                          │                                                                                                 │
│ lib/cli/index.js#8416                                        │ submitBom                                 │                                                                                                          │ _tmp_775                                                                                        │
│                                                              │ Tags: exported                            │                                                                                                          │                                                                                                 │
│ lib/cli/index.js#8416                                        │ submitBom                                 │ got(serverUrl, {                                                                                         │ got:got ⤴                                                                                       │
│                                                              │ Tags: http-client                         │           method: "POST",                                                                                │                                                                                                 │
│                                                              │                                           │           https: {                                                                                       │                                                                                                 │
│                                                              │                                           │             rejectUnauthorized: !args.skipDtTlsCheck,                                                    │                                                                                                 │
│                                                              │                                           │           },                                                                                             │                                                                                                 │
│                                                              │                                           │           headers: {                                                                                     │                                                                                                 │
│                                                              │                                           │             "X-Api-Key": args.apiKey,                                                                    │                                                                                                 │
│                                                              │                                           │             "Content-Type": "application/json",                                                          │                                                                                                 │
│                                                              │                                           │             "user-agent": `@CycloneDX/cdxgen ${_version}`,                                               │                                                                                                 │
│                                                              │                                           │           },                                                                                             │                                                                                                 │
│                                                              │                                           │           json: bomPayload,                                                                              │                                                                                                 │
│                                                              │                                           │           responseType: "json",                                                                          │                                                                                                 │
│                                                              │                                           │         })                                                                                               │                                                                                                 │
└──────────────────────────────────────────────────────────────┴───────────────────────────────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────┘
                                                                                                                                                  Source: options = {}
                                                                                                                                        Sink: lib/cli/index.js::program:submitBom
                                                                                                                                                 Sink Tags: http-client

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions