this post was submitted on 10 Jul 2023
1395 points (98.7% liked)

Lemmy.World Announcements

30084 readers
1875 users here now

This Community is intended for posts about the Lemmy.world server by the admins.

Follow us for server news 🐘

Outages πŸ”₯

https://status.lemmy.world/

For support with issues at Lemmy.world, go to the Lemmy.world Support community.

Support e-mail

Any support requests are best sent to [email protected] e-mail.

Report contact

Donations πŸ’—

If you would like to make a donation to support the cost of running this platform, please do so at the following donation URLs.

If you can, please use / switch to Ko-Fi, it has the lowest fees for us

Ko-Fi (Donate)

Bunq (Donate)

Open Collective backers and sponsors

Patreon

Join the team

founded 2 years ago
MODERATORS
 

While I was asleep, apparently the site was hacked. Luckily, (big) part of the lemmy.world team is in US, and some early birds in EU also helped mitigate this.

As I am told, this was the issue:

  • There is an vulnerability which was exploited
  • Several people had their JWT cookies leaked, including at least one admin
  • Attackers started changing site settings and posting fake announcements etc

Our mitigations:

  • We removed the vulnerability
  • Deleted all comments and private messages that contained the exploit
  • Rotated JWT secret which invalidated all existing cookies

The vulnerability will be fixed by the Lemmy devs.

Details of the vulnerability are here

Many thanks for all that helped, and sorry for any inconvenience caused!

Update While we believe the admins accounts were what they were after, it could be that other users accounts were compromised. Your cookie could have been 'stolen' and the hacker could have had access to your account, creating posts and comments under your name, and accessing/changing your settings (which shows your e-mail).

For this, you would have had to be using lemmy.world at that time, and load a page that had the vulnerability in it.

top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 97 points 2 years ago (2 children)

IMPORTANT ANNOUNCEMENT: My account was not among those hacked. Any random bullshit appearing in my post/comment history was written by me.

load more comments (2 replies)
[–] [email protected] 88 points 2 years ago (10 children)

Very impressed by how quickly action has been taken by this and other instances to patch the issue.

[–] [email protected] 13 points 2 years ago

Very, seems like great work.

[–] [email protected] 12 points 2 years ago* (last edited 2 years ago) (12 children)

Hijacking the top comment to say I had problems with logging in to Lemmy.world today and liftoff was failing in odd ways.

I had to go into my web browser and clear my site cookies for lemmy.world to let me log in there.

In liftoff I had to go into the app settings in android to clear the cache and then remove and re-add my account for it to be able to log me in. (Press and hold on the account to remove it)

load more comments (12 replies)
load more comments (8 replies)
[–] [email protected] 72 points 2 years ago (9 children)

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] 23 points 2 years ago* (last edited 2 years ago) (1 children)

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

I'm a modern web developer who used to be an old-school one.

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.

Yeah - pretty much, though there are some mitigating factors.

Strictly speaking, it was the alt text for the emoji. Alt text is HTML, and rather than allow arbitrary HTML they allowed another language called Markdown. Markdown is "a plain text" language with human readable syntax specifically designed to be converted into HTML.

Markdown is the right format to use for emoji alt texts, but you do need to be careful of one thing - the original purpose of Markdown was to allow HTML content to be easier to write/read and it is a superset of the HTML language. So arbitrary HTML is valid markdown.

Virtually all modern Markdown parsers disable arbitrary HTML by default, but it's a behaviour which can be changed and that leaves potential for mistakes like this one here. Specifically the way Lemmy injected emojis with alt text into the Markdown content allowed arbitrary HTML.

This wasn't an obvious mistake - the issue over on Lemmy's issue tracker is titled "Possible XSS Attack" because they knew there was an XSS Attack somewhere and they weren't immediately sure if they had found it in the emoji system. Even now reading the diff to fix the vulnerability, it still isn't obvious to me what they did wrong.

It's fairly complex code and complexity is the enemy of security... but sometimes you have to do complex things. Back in the "old-school" days, nobody would have even attempted to write something as complicated as a federated social network...

JavaScript (TypeScript) has access to cookies (and thus JWT). This should be handled by web browser, not JS.

Yeah - the Lemmy developers made a mistake there. There are a few things they aren't doing right around cookies and JWT tokens.

Hopefully they fix it. I expect they will... It was already actively being discussed before this incident, and those discussions have been seen by a lot more people now.

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.

There are several levels of isolation that could have blocked this:

  1. Users should not be able to inject arbitrary HTML.
  2. A flag on the page should be set telling the browser to ignore JavaScript in the body of the page - this is a relatively new feature in the web and disabled by default for obvious backwards compatibility reasons, but it should be set especially on a high value target like Lemmy, and I expect once it's been around a little longer browsers will enable it by default.
  3. A flag should have been set to block JavaScript from contacting an unknown third party domain. Again, this isolation is a relatively new web feature and currently disabled by default.
  4. As you say, JavaScript shouldn't be able to access the JWT token or the cookie. That's not a new feature in the web, it's just one Lemmy developers didn't take advantage of (I don't know why)
  5. Even if all of those previous levels of isolation failed... there are things Lemmy should be doing to mitigate the attack. In particular instance admins have had to manually reset JWT tokens. Those tokens should have expired somehow on their own - possibly the moment the attacker tried to use 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.

Yep - the modern best practice is for admins to manage the site via a completely different system. That adds considerable complexity and cost though, so it's rarely done unfortunately. But you know, Lemmy is open source... so if someone wants to take on that work they can do it.

I'll add one more - it should have taken less time to close the exploit... but given this is the first serious exploit I'll forgive that.

Ultimately several of failures contributed to this attack. I expect many of those failures will be corrected in the coming weeks, and that will make Lemmy far more secure than it is right now - so that next time there's a bug like the one in the Markdown parser it isn't able to cause so much disruption.

The good news is no harm was done, and a lot of people are going to learn some valuable lessons as a result of this incident. Ultimately the outcome is a positive one in my opinion.

load more comments (1 replies)
[–] [email protected] 9 points 2 years ago (5 children)

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).

load more comments (5 replies)
[–] [email protected] 9 points 2 years ago (1 children)

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.

JavaScript needs access to the cookies, they are the data storage for a given site.
To protect them, the browser silos them to the individual site that created them, that's why developers haven't been able to easily load cross domain content for years, to mitigate XSS attacks.
The security relies on the premise that the only valid source of script is the originating domain.
The flaw here was allowing clients to add arbitrary script that was displayed to others.
You're dead right that only the way to fix this is to do away with JavaScript access to certain things, but it will require a complete refactor of how cookies work.
I haven't done any web dev in a few years, this might even be a solved problem by now and we are just seeing an old school implementation. 🀷

[–] [email protected] 9 points 2 years ago (1 children)

this might even be a solved problem by now

Yes, it is called HttpOnly and is decided by the server who is sending the cookie to you in HTTP response header. I believe there are also HTTPS-only cookies that when received via HTTPS, cannot be used from HTTP, but I cannot find it right now.

load more comments (1 replies)
load more comments (6 replies)
[–] [email protected] 69 points 2 years ago (31 children)

I wish hackers would invest their time in clearing credit card debt, deleting hospital fees, or something else that actually serves the public good, instead of hacking ordinary people just trying to get by.

[–] [email protected] 24 points 2 years ago (2 children)

Deleting hospital fees/debt is very dangerous... In many HUGE regions in the US there's only one hospital and if that hospital suddenly can't pay its bills it could shut down, leaving a whole lot of completely innocent people in a very sad, people-are-dying sort of state.

In fact, something like this already happened:

https://www.cbsnews.com/chicago/news/st-maragrets-health-central-illinois-hospital-closing/

Hospitals are special in that they're often evil organizations (not all though) that are some of the easiest to hack but also provide critical services to the most vulnerable. One should tread lightly. Political solutions are better (hack some politicians that are against healthcare reform instead).

Clearing credit card debt via hacking is nearly impossible but I agree it would be a much more ethical choice for hackers to target. I used to work for the credit card industry. My unique insider perspective, deep industry knowledge, and personal experience is here to let you know they suck. They are just as evil and unethical and unnecessary as everyone thinks they are! Seriously: If Visa, MasterCard, American Express, and all the lesser players suddenly disappeared the world would be a better place.

Before that can happen though people need a backup payment method that doesn't go through their systems and no: Cash won't work (there's not enough in circulation and it's dangerous to carry large amounts of it). The credit card companies know this threat exists which is why they lobbied Florida (and probably other states) to outlaw alternative, government-run forms of payment (e.g. central bank currency).

As soon as people have a widely accepted payment option that doesn't go through Visa and MasterCard's middlemen (e.g. First Data) then hackers can take their gloves off! Until then though... Let's keep the payment infrastructure working, OK? Thanks!

There's no limit to the amount of good deeds hackers can do though. So let's encourage that! For example, there's plenty of cartels and evil religious organizations (e.g. Taliban, ISIS, Mormon Church, Prosperity Gospel scam artists) that have plenty of money to spare and enormous attack surfaces πŸ‘

[–] [email protected] 21 points 2 years ago

Hospitals are special in that they’re often evil organizations

Just want to state the obvious and say, this is pretty much only the case in the US.

load more comments (1 replies)
load more comments (30 replies)
[–] [email protected] 51 points 2 years ago (6 children)

Good thing we all use randomly generated passwords for every account and always remember to change them every few months.

[–] [email protected] 24 points 2 years ago

Passwords are safe, it's temporary session tokens (already invalidated) that were exposed.

[–] [email protected] 16 points 2 years ago

Good call.

However, that wouldn't have prevented this from happening. Not even MFA can protect you in case of an exploit like this.

load more comments (4 replies)
[–] [email protected] 34 points 2 years ago (1 children)

Thank the heavens the meme community stayed safe through this without my daily dose of cybersecurity memes idk how I would function ;)

load more comments (1 replies)
[–] [email protected] 32 points 2 years ago (7 children)

Thanks Ruud for fixing it! Just a reminder guys that If you are using a third party app you need to login again.

[–] [email protected] 12 points 2 years ago (2 children)

Further 3rd party heads up -- for us nontech refugees:

If it looks like you are logged in, you may not be. I use Connect, and at your reminder, I clicked my acct and it says I was logged in. I tried to comment that Connect login was working, and my comment didn't show up.

I tried again, only to see an ”error: not logged in” message pop up.

Signed out, signed in again manually, and all is well.

So do a double check, Lemurs. Trust in your actions, not your eyes.

load more comments (2 replies)
load more comments (6 replies)
[–] [email protected] 29 points 2 years ago (1 children)

One wonders how much spez paid for that hack.

load more comments (1 replies)
[–] [email protected] 27 points 2 years ago

You guys really have my highest respect for spending so much time to keep this running, despite all the recent trouble and now even an attack.

Thank you very much <3 You guys are awesome and I really appreciate how publicly you deal with this.

[–] [email protected] 26 points 2 years ago (20 children)

I think this is a strong reminder: We shouldn't put all our eggs in one basket. This will happen again. Unlike Reddit, we don't need to concentrate all communities on one instance. We should all make an effort to spread out. Some other general use instances are:

Again, for those new, you can post content to any of these instances and interact with content from other instances at the same time, just like you can send an email from your Gmail account to your ProtonMail account.

[–] [email protected] 12 points 2 years ago

This was an exploit in lemmy software and affected multiple instances though

load more comments (19 replies)
[–] [email protected] 21 points 2 years ago (1 children)

Any truth to what I've heard this may have been done by a group we defederated with?

load more comments (1 replies)
[–] [email protected] 20 points 2 years ago

Thanks for fixing and being so open about it

[–] [email protected] 16 points 2 years ago (8 children)

On Liftoff, I had to clear cache and storage in order to log back in. Still having issues with the website on Chrome, which keeps telling me I'm not logged in after clearing cache and logging back in.

load more comments (8 replies)
[–] [email protected] 16 points 2 years ago

The quick fix is much appreciated, thank you and everyone that helped for your hard work!

[–] [email protected] 16 points 2 years ago* (last edited 2 years ago) (4 children)

FYI: I had to clear my lemmy.world cookies in order to be able to successfully log back in.

(This was with Firefox)

(Edit: I also shift-clicked reload, which somebody pointed out does clean the cache for that page, so I also cleaned the cache).

load more comments (4 replies)
[–] [email protected] 16 points 2 years ago (1 children)

what steps are being taken to ensure it doesn't happen again? was any personal data compromised for users?

[–] [email protected] 15 points 2 years ago (20 children)

Good point, I'll update the post.

load more comments (20 replies)
[–] [email protected] 16 points 2 years ago (2 children)

At least now we can mark off the "disruptive website defacement attack" line on the checklist of (relatively) new website growing pains. Better to have them make lots of noise and get fixed quickly than quietly do sneaky things in the background.

load more comments (2 replies)
[–] [email protected] 14 points 2 years ago (4 children)

I just disabled whole "/admin" section on my instance and added nice message πŸ˜†

load more comments (4 replies)
[–] [email protected] 14 points 2 years ago (1 children)

This is really good to see such transparency from admins

load more comments (1 replies)
[–] [email protected] 13 points 2 years ago (1 children)

That doesn't surprise me. Especially the "homemade" instances. The documentation is severely lacking and I had to fix lots of stuff in the instructions with try&despair to make my instance run.

There's not a great focus in security if your application starts with "step 1: install docker"

load more comments (1 replies)
[–] [email protected] 12 points 2 years ago (2 children)

Ugh, people should not go after systems trying to give a free service to the internet. It just ruins everything.

load more comments (2 replies)
[–] [email protected] 12 points 2 years ago

Thanks for letting us know - this is the kind of transparency that I wish the world had more of!

[–] [email protected] 12 points 2 years ago

Thanks for the great work. The response time was awesome, considering you were asleep as well.

[–] [email protected] 11 points 2 years ago* (last edited 2 years ago) (9 children)

Do we have any details on how Michelle's account was compromised? Right now in the GitHub issue about the vulnerability they're clueless about how the custom emoji exploit could be performed without first an already compromised admin account.

EDIT: yeah here's how: https://github.com/LemmyNet/lemmy-ui/issues/1895#issuecomment-1629326627

You do NOT need an admin account to do that. Any normal user could have done that.

load more comments (9 replies)
[–] [email protected] 11 points 2 years ago

Despite the fact that Lemmy is a fairly new piece of software, which makes these issues more likely, I am really grateful for it being open source, and I really appreciate this level of transparency.

[–] [email protected] 11 points 2 years ago (4 children)

I had to create a new account. I tried enabling 2FA on my main account a week ago, but was never able to generate a token. Now when I try logging in it is asking for my 2FA token. Is there any way to get my account back. I'm a moderator of a community.

load more comments (4 replies)
[–] [email protected] 10 points 2 years ago* (last edited 2 years ago) (15 children)

First - really good summary and sounds like everyone is working hard.

Cross posting the below comment.

Under GDPR if you have had a data breach you have a legal obligation to assess whether you need to report it and you must make the report within 72 hours of discovering the breach.

There are other types of reportable breaches too, I only mention data as it sounds most likely. You may or may not be subject to PECR which may also have been breached although less likely. I don’t really have enough familiarity with the regulation to discuss that one.

If you are not sure if there has been a breach you may also need to discuss it with the relevant body or make a report.

Please can you update what action you have taken regarding this and if the incident was reportable or not and the reasons why. Edit - from that new information, it sounds like this is a reportable breach.

For a full understanding, it would be good to know if you had 2FA enabled on the compromised account particularly as it had admin privileges and if so how 2FA was circumvented with this exploit.

It would also be good to know what measures you have in place to prevent the same or other malicious attempts on your Open Collective and Patreon accounts as issues with those are potentially more serious. They may not be vulnerable to this, but it is going to be reassuring to know there is good security practice, 2FA protection etc enabled and you have robust procedures in place.

[–] [email protected] 10 points 2 years ago

Thanks for the info. We're looking into this.

load more comments (14 replies)
[–] [email protected] 10 points 2 years ago (1 children)

Once again, thank you guys for all that you do. As many other people are saying, appreciate the transparency about these things.

load more comments (1 replies)
[–] [email protected] 10 points 2 years ago (2 children)
load more comments (2 replies)
[–] [email protected] 10 points 2 years ago (11 children)

I can only log in on incognito mode, which makes me think my cookie has been stolen or whatever. So my question is, what should I be doing about that?

load more comments (11 replies)
[–] [email protected] 9 points 2 years ago (1 children)

Damn, I go to bed early and I miss everything! Thanks for the quick resolution and transparent disclosure, this place is great!

load more comments (1 replies)
[–] [email protected] 9 points 2 years ago

This is so sad lmao rip. With any site growing as fast as these instances (because of the Reddit folk) Ig these attacks are to be expected. Hope everyone's accounts and personal info are okay

load more comments
view more: next β€Ί