6
submitted 1 year ago* (last edited 1 year ago) by [email protected] to c/[email protected]

Drawing attention on this instance so Admins are aware and can address the propagating exploit.

EDIT: Found more info about the patch.

A more thorough recap of the issue.

GitHub PR fixing the bug: https://github.com/LemmyNet/lemmy-ui/pull/1897/files

If your instance has custom emojis defined, this is exploitable everywhere Markdown is available. It is NOT restricted to admins, but can be used to steal an admin's JWT, which then lets the attacker get into that admin's account which can then spread the exploit further by putting it somewhere where it's rendered on every single page and then deface the site.

If your instance doesn't have any custom emojis, you are safe, the exploit requires custom emojis to trigger the bad code branch.

top 15 comments
sorted by: hot top controversial new old
[-] [email protected] 1 points 1 year ago

I’m greatly surprised how Lemmy and the fediverse society has responded with this. The bug was found yesterday, maybe? And I’ve read about it three, four times (in different servers); a temporal solution was published in hours and it’s already patched on the repo.

Another victory for Open Source and the Fediverse in general.

[-] [email protected] 1 points 1 year ago

More importantly the issue was tracked and resolved publicly.

The issue of trust in corporate spaces gets used to bury these things, this is a good model on how to restore it in the open.

[-] [email protected] 1 points 1 year ago

I firmly believe open source is the future of software development and things like this really show off the strengths of this sort of collaborative work. Everyone benefits and it’s a great way to maintain high quality.

[-] [email protected] 1 points 1 year ago

This is what happens when the people running a platform actually care about it and it's users

[-] [email protected] 1 points 1 year ago

Security is crazy hard and having perfect security is impossible. Kudos to the dev team for resolving this so quickly.

[-] [email protected] 1 points 1 year ago

In my opinion, the project would benefit from static vulnerability scanning. Low hanging fruit like this XSS would have definitely been flagged.

Most of those providers even give it out for free for open source projects. So it wouldn’t hurt.

[-] [email protected] 0 points 1 year ago

So what happened:

  • Someone posted a post.
  • The post contained some instruction to display custom emoji.
  • So far so good.
  • There is a bug in JavaScript (TypeScript) that runs on client's machine (arbitrary code execution?).
  • The attacker leveraged the bug to grab victim's JWT (cookie) when the victim visited the page with that post.
  • The attacker used the grabbed JWTs to log-in as victim (some of them were admins) and do bad stuff on the server.

Am I right?

I'm old-school developer/programmer and it seems that web is peace of sheet. Basic security stuff violated:

  • User provided content (post using custom emojis) caused havoc when processing (doesn't matter if on server or on client). This is lack of sanitization of user-provided-data.
  • JavaScript (TypeScript) has access to cookies (and thus JWT). This should be handled by web browser, not JS. In case of log-in, in HTTPS POST request and in case of response of successful log-in, in HTTPS POST response. Then, in case of requesting web page, again, it should be handled in HTTPS GET request. This is lack of using least permissions as possible, JS should not have access to cookies.
  • How the attacker got those JWTs? JavaScript sent them to him? Web browser sent them to him when requesting resources form his server? This is lack of site isolation, one web page should not have access to other domains, requesting data form them or sending data to them.
  • The attacker logged-in as admin and caused havoc. Again, this should not be possible, admins should have normal level of access to the site, exactly the same as normal users do. Then, if they want to administer something, they should log-in using separate username + password into separate log-in form and display completely different web page, not allowing them to do the actions normal users can do. You know, separate UI/applications for users and for admins.

Am I right? Correct me if I'm wrong.

Again, web is peace of sheet. This would never happen in desktop/server application. Any of the bullet points above would prevent this from happening. Even if the previous bullet point failed to do its job. Am I too naïve? Maybe.

Marek.

[-] [email protected] 0 points 1 year ago

Oh I forgot another line of defense / basic security mitigation. If a server produces an access token (such as JWT or any other old school cookie / session ID), pair it with an IP address. So in case of cookie theft, the attacker cannot use this cookie from his computer (IP address). If the IP changes (mobile / WiFi / ADSL / whatever), the legitimate user should log-in again, now storing two auth cookies. In case of another IP change, no problemo, one of the stored cookies will work. Of course limit validity of the cookie in time (lets, say, keep it valid only for a day or for a week or so).

[-] [email protected] 1 points 1 year ago

I'm sorry you want a mobile user to login every time their IP address changes? Why bother to keep them authenticated at all, just make them login for every web request. /s

[-] [email protected] -1 points 1 year ago

It is trade-off between convenience and security. With my approach stolen cookies are not usable from different computer / IP, the attacker needs additional work, he needs the victim computer to do the harm, his computer cannot do any harm. The downside is the user needs another log-in in case of his external IP changes. How often is it? Switch between mobile/WiFi. Otherwise ... almost never ... maybe 1x per day? I'm not proposing to log-out the user after IP change, I'm proposing to keep multiple sessions (on server) / auth cookies (on client) for each IPv4 or IPv6 prefix (let's say /56).

[-] [email protected] 0 points 1 year ago

And this is why you don't trust tankies. It's very easy to compromise the software and put back doors into it.

Use kbin instead.

And this is not me saying that this is a case of that, this is me saying that this could be the case in the future

[-] [email protected] 1 points 1 year ago

And this is why you don’t trust tankies

What are you referring to here?

[-] [email protected] 0 points 1 year ago

Tbf, there are far more pressing reasons for distrusting Tankies... Instances getting hacked is for sure aggravating, but it isn't the gulag-backed paranoid ultra-corrupt authoritarian hellhole they so admire and wish to expand globally.

[-] [email protected] 0 points 1 year ago

This is a ridiculous take and fairly toxic. Don't ruin any communities with unnecessary hate. It's unwanted.

[-] [email protected] 0 points 1 year ago

This is the dumbest possible take about the situation, my lord.

this post was submitted on 10 Jul 2023
6 points (87.5% liked)

Programming.dev Meta

2445 readers
1 users here now

Welcome to the Programming.Dev meta community!

This is a community for discussing things about programming.dev itself. Things like announcements, site help posts, site questions, etc. are all welcome here.

Links

Credits

founded 1 year ago
MODERATORS