Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

traceo-sdk-browser. Bug in BrowserClient.handleOnUnhandledRejectionEvent #11

Open
AlexeyBarsuk opened this issue Oct 12, 2024 · 1 comment

Comments

@AlexeyBarsuk
Copy link

The handleOnUnhandledRejectionEvent of BrowserClient contains the code below

const reason = data.event.reason;
....
let stack = "";
if ("stack" in reason) {
  stack = reason.stack;
} else {
  stack = reason.toString();
}

It is said in documentation that PromiseRejectionEvent property "reason" can be either Object or some other value. In case "reason" is not Object, the error is ocured.

Снимок экрана 2024-10-12 в 20 09 23

In order to quick fix this issue there is a way to change the condition

if ("stack" in reason)

to

if (typeof reason == "object" && "stack" in reason)

Sorry, have no ability to make PR :(

@AlexeyBarsuk
Copy link
Author

AlexeyBarsuk commented Oct 12, 2024

This leads to empty stack is sent to Traceo server. After that the incidents page stops working correct (some errors happens in frontend, and nothing is shown on page). This can be worked around by adding dummy Trace object. I will not post the code here, because all this is ugly.

Moreover if not to fix this bug BrowserIncidentType.name with single quote is sent to Traceo server. And it also leads to problems with traceo server, because this single quote is used in SQL query in getIncedent method, and becomes the part this query for Traceo 1.2.5 release

Снимок экрана 2024-10-12 в 19 45 25

This problem is fixed in this issue in developer branch, however the latest release 1.2.5 has this bug. I think in some cases this bug can be used for sql injection to server.

Снимок экрана 2024-10-12 в 23 13 52

So, developers, please fix these things. Sorry for this, a little bit of emotions drives me.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant