Skip to content

0000 00 16 3e dd 1c 8c #918

Open
Open
@TheProdigyLeague

Description

@TheProdigyLeague

Error occurring within http-server repository code, specifically within the read-package-json-fast mod.

Location: The error is happening within the file /usr/local/share/.rvm/rubies/ruby-2.7.7/lib/ruby/gems/2.7.0/gems/npm-normalize-package-bin-1.0.1/node_modules/read-package-json-fast/index.js.

http-server is utilizing read-package-json-fast - mod.

Error Type: SyntaxError: Unexpected token.

JavaScript 解析器在代码中遇到了一些意料之外的事情。

Location: The error is pinpointed to line 18, column 5 of the index.js file within read-package-json-fast.

Context:

if (!!(pos = string.indexOf(sep, pos + 1))
Call Stack:
at anongymous
at parse
at loadNodeModule

... and further up the stack within http-server's execution.

Hex Dump: 0000 00 16 3e dd 1c 8c

The read-package-json-fast mod is attempting to parse a string:

!!(pos = string.indexOf(sep, pos + 1)) 

Source of the Malformed Data: What data is read-package-json-fast trying to parse when this error occurs? Is it:
A package.json file from a dependency? If so, could a maliciously crafted dependency with a malformed package.json cause this error and potentially disrupt the http-server's functionality?
Some other configuration file or data related to how http-server handles modules or packages?
Impact of the Error: What happens when this error occurs? Does it:
Cause the http-server to crash or become unstable (a denial-of-service vulnerability)?
Prevent the server from correctly loading modules or configurations, potentially leading to unexpected behavior?
Expose any error messages or stack traces that could reveal sensitive information about the server's internal workings?
Control Over the Malformed Data: Can a user or attacker influence the content of the data being parsed? For example, if http-server allows serving user-uploaded package.json files (unlikely but hypothetically), a malicious user could try to trigger this error.
Dependency Vulnerabilities: The fact that this error occurs within a dependency (read-package-json-fast) highlights the importance of auditing the dependencies of http-server for known vulnerabilities. Even if this specific error isn't directly exploitable, other issues in the dependency chain could be.
In summary, while the immediate error appears to be a parsing issue, a security researcher would investigate the source and impact of this malformed data. They would want to understand if an attacker could control this data to cause a denial-of-service or other unintended consequences. Furthermore, this highlights the need for a thorough dependency audit.

The researcher's next steps might involve:

Identifying the specific package.json file or data that triggers this error.
Analyzing the content of that data to understand the "unexpected token."
Tracing how http-server uses the read-package-json-fast module in this context.
Determining if a malicious actor could influence the content being parsed.
Checking for known vulnerabilities in the read-package-json-fast module.

Environment Versions

  1. Intel Alder Lake Chromebook (omnigul, version 135.16209.0)
  2. v22.15.0
  3. v14.1.1

Steps to reproduce

  1. http-server ./public -p 8080 --cors -H "X-Custom-Header: value"
  2. npx http-server [run][]
  3. \escape

Expected result

provide input via command-line options when starting the server

Actual result

Image

...

Other information

No Bubble DOM

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions