this post was submitted on 21 Mar 2025
674 points (99.4% liked)

Programmer Humor

22274 readers
1936 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 

Original post: hachyderm.io (Mastodon)

you are viewing a single comment's thread
view the rest of the comments
[–] jjjalljs@ttrpg.network 91 points 2 weeks ago (5 children)

Is the backend Python and the frontend JavaScript? Because then that would happen and just be normal, because Boolean true is True in python.

[–] testfactor@lemmy.world 138 points 2 weeks ago (4 children)

Probably, but if you're interpreting user inputs as raw code, you've got much much worse problems going on, lol.

[–] LostXOR@fedia.io 36 points 2 weeks ago (1 children)

[...]&register=import os; os.system("sudo rm -rf /"); return True

[–] MajorHavoc@programming.dev 18 points 2 weeks ago

Hey, that's my username too. Or it was going to be, while the site was still up.

What a coincidence!

I guess I'll wait for the site to come back, and see if it's still available...

[–] mmddmm@lemm.ee 19 points 2 weeks ago (1 children)

It's the settiings file... It's probably supposed to only be written by the system admin.

[–] raldone01@lemmy.world 9 points 2 weeks ago* (last edited 2 weeks ago) (2 children)

A good place to put persistent malware. That's why when using docker images always mount as ro if at all possible.

[–] ashley@lemmy.ca 8 points 2 weeks ago (1 children)

It’s you can modify the settings file you sure as hell can put the malware anywhere you want

[–] MajorHavoc@programming.dev 1 points 2 weeks ago* (last edited 2 weeks ago)

It’s you can modify the settings file you sure as hell can put the malware anywhere you want

True. (But in case it amuses you or others reading along:) But a code settings file still carries it's own special risk, as an executable file, in a predictable place, that gets run regularly.

An executable settings file is particularly nice for the attacker, as it's a great place to ensure that any injected code gets executed without much effort.

In particular, if an attacker can force a reboot, they know the settings file will get read reasonably early during the start-up process.

So a settings file that's written in code can be useful for an attacker who can write to the disk (like through a poorly secured upload prompt), but doesn't have full shell access yet.

They will typically upload a reverse shell, and use a line added to settings to ensure the reverse shell gets executed and starts listening for connections.

Edit (because it may also amuse anyone reading along): The same attack can be accomplished with a JSON or YAML settings file, but it relies on the JSON or YAML interpreter having a known critical security flaw. Thankfully most of them don't usually have one, most of the time, if they're kept up to date.

[–] mmddmm@lemm.ee 3 points 2 weeks ago

Every environment has plenty of good places to put persistent malware. Even if you run your docker images as ro.

[–] 0x0@lemmy.dbzer0.com 8 points 2 weeks ago (1 children)

Given the warning about capitalization, the best possible case is that they're using ast.literal_eval() rather than throwing untrusted input into eval().

Err, I guess they might be comparing strings to 'True' and are choosing to be really strict about capitalization for some reason.

[–] MajorHavoc@programming.dev 12 points 2 weeks ago

Yeah. Maybe .to_lower() is really expensive in their environment, lol.

[–] SchwertImStein@lemmy.dbzer0.com 5 points 2 weeks ago

It's not User input, it's config file

[–] shortrounddev@lemmy.world 21 points 2 weeks ago (1 children)

I curse the sadist who decided True should be uppercase in Python

[–] jdeath@lemm.ee 3 points 2 weeks ago (1 children)

guido, why did you make python so weird?

[–] palordrolap@fedia.io 8 points 2 weeks ago (1 children)

In this instance, I think there was some suggestion to write code in mostly lower case, including all user variables, or at least inCamelCaseLikeThis with a leading lower case letter, and so to make True and False stand out, they've got to be capitalised.

I mean. They could have been TRUE and FALSE. Would that have been preferable? Or how about a slightly more Pythonic style: __true__ and __false__

[–] jdeath@lemm.ee 4 points 2 weeks ago

i would go with lowercase and just have it be a reserved word like the other ones. but I'm not super picky, i generally like to stick to what people are used to, and i can understand the reasoning behind the choice.

[–] Aatube@kbin.melroy.org 16 points 2 weeks ago (3 children)

Can't they just convert a "true" input to backend to uppercase

[–] PotatoesFall@discuss.tchncs.de 28 points 2 weeks ago

Yep they should use a config file format like JSON or TOML or YAML or what have you, and then decode that into python objects. Using an actual programming language for config is dumb as hell IMO. (inb4 pissed off suckless fans)

[–] jjjalljs@ttrpg.network 5 points 2 weeks ago (1 children)

Depends on how it's set up. If the setting is going into the env it's a string, so I'd expect some sort of

if os.getenv("this_variable", "false").lower() == "true":   # or maybe "in true, yes, on, 1" if you want to be weird like yaml
  this_variable = True
else:
  this_variable = False

Except maybe a little more elegant and not typed on my phone.

But if the instructions are telling the user to edit the settings directly, like where I wrote this_variable=True, they'd need to case it correctly there.

[–] fushuan@lemm.ee 2 points 2 weeks ago (1 children)

Fyi, using a condition to assign a boolean is equivalent to assigning the condition itself. No need for the IF.

[–] jjjalljs@ttrpg.network 2 points 2 weeks ago

true, though sometimes i find the more verbose style easier to read, and more maintainable (eg: you want to do something else in the block, you can just add a line instead of changing your ternary / etc). Small things

[–] hersh@literature.cafe 4 points 2 weeks ago

I refer you to #7 on Bruce Tognazzini's evergreen top ten list of design bugs.

https://www.asktog.com/Bughouse/10MostWantedDesignBugs.html

[–] MHLoppy@fedia.io 9 points 2 weeks ago

Searching for the phrase, documentation matches for Taiga so maybe you're right!