Skip to main content

Error'd: There's a Chill in the Air

2 days 13 hours ago

There's a bathroom on the right!

"Interesting temperature reading from WU" notes Peter G. "This must be what happens when a bulk liquid nitrogen carrier runs aground in your favourite holiday spot. Either that or you're supposed to take the average of +60 and -40 to get the actual temperature."

At the same time, an anon mutters "I think someone left the freezer door open."

And an anonagain loves "M$ SharePoint security. Need I say more?"

Furry friend The Beast in Black growls "This unique hotel amenity is one I haven't yet seen offered elsewhere and is one I'll certainly be using."

Until John remembers that "AI's are not causing the memory shortage, they claim to be solving it! Hopefully the stochastic approximations will not spread any further through the operating system." It just depends on what the meaning of the word is is.

[Advertisement] Keep all your packages and Docker containers in one place, scan for vulnerabilities, and control who can access different feeds. ProGet installs in minutes and has a powerful free version with a lot of great features that you can upgrade when ready.Learn more.
Lyle Seaman

CodeSOD: A Living Fossil

3 days 13 hours ago

Today's anonymous submission is a blast from the past. This comes from an intranet HTML page that has been receiving continuous updates for some time. How long? Well, let's take a peek at how it does its layout.

<b>Extension:</b> x5555<br /> <b>Email:</b>: <a href="mailto:blahblah@example.com"></a><br /><br /> </td> <td width=140> </td> </tr> <tr><td>&nbsp;</td></tr> <tr><td>&nbsp;</td></tr> </td> </table> </center> <!-- END DIRECTORY --> <tr><td><br /></td></tr> </td> </tr> </table> <!-- MATERIAL ENDS HERE --> <br /> <br /> </td> </tr> </table> </center> </td> </tr> <tr><td width=987 height=4 background="../images/table_bottom_sidebar.jpg"></td></tr> </table>

This is like a coelecanth, or a horeshoe crab. A living fossil. There are hints that imply this started life as the output of a WYSIWYG editor, like Dreamweaver or something. The loads of line break tags, the table cells that contain only a space, and also the one table cell that contains a line break- that feels like a WYSIWYG trying to interpret what the user types. But the comments imply someone was also looking at the HTML code at some point. And certainly, in the modern era, it is being edited by someone with a text editor.

The absence of CSS might point us towards a late 90s website, as by the early 00s, CSS was starting to become standard, but the thing that really pins this in a point in time is the XHTML style self-closing <br /> tags.

But then little quirks highlight that someone was also getting "creative" with code. The table_bottom_sidebar.jpg had related images, all designed to put borders in the table. There were matching images for left, right, and top borders.

Our submitter adds: "Needless to say, this site is being replaced."

Replaced? It should get a historical marker. This is how we used to do it, in the bad old days. We'd add <br />&nbsp; while churning butter in homespun dresses, and we liked it.

Okay, we didn't like it. But still.

[Advertisement] Keep all your packages and Docker containers in one place, scan for vulnerabilities, and control who can access different feeds. ProGet installs in minutes and has a powerful free version with a lot of great features that you can upgrade when ready.Learn more.
Remy Porter

Representative Line: Terning White as a (Style)Sheet

4 days 13 hours ago

Years ago, Stefan's company was short handed, especially on the developer team. But they had a large hell-desk support team. And at some point, someone had the genius idea: "PHP is easy for anyone to learn, and so our helpdesk folks should have no problem. Let's hand them development tasks."

Which meant Stefan inherited lots of lines which look like this:

$bgc = $tno ? '#FFFFFF' : '#FFFFFF';

Unlike many examples of this pattern, this is not the result of a pre-processing or templating step generating a conditional where both branches are the same value. Someone actually typed this. Also, notably, the variable $tno holds a numeric value, not a boolean, and is never null. It sometimes is zero, which is false, but zero is just a regular value it might hold, and thus it shouldn't get any special formatting.

In short, the ternary shouldn't be here, not just because both branches are the same thing, but because there shouldn't logically be any branching at all.

[Advertisement] ProGet’s got you covered with security and access controls on your NuGet feeds. Learn more.
Remy Porter

CodeSOD: Building a Line

5 days 13 hours ago

There's an unofficial category of posts here that I call "Somebody told us string builders were more efficient, so we always use string builders, regardless of whether or not that actually makes sense," or STUSBWMESWAUSBROWONTAMS, for short. Probably should workshop that name some.

In any case, Adam sends us a new entry for that collection:

Public Function ReadFromFile(ByVal filename As String) As String Dim sb As StringBuilder = New StringBuilder() Dim str As String = String.Empty Using sr As StreamReader = File.OpenText(filename) str = sr.ReadToEnd() sb.Append(str & Constants.vbLf) End Using Return sb.ToString() End Function

This function takes a filename, opens a file, reads the entire contents of the file to a variable. It concatenates a line feed to the end of the string it just read, then appends all of that to a string builder. Finally, we return sb.ToString(), taking the single string in the string builder, appending nothing to it, and returning the result.

I'd almost, almost forgive the code if it was more like:

str = sr.ReadToEnd() sb.Append(str) sb.Append(Constants.vbLf)

You're not actually gaining much from this, but it follows the broad pattern of "use a string builder" so that if you ever wanted to change the structure of the output, you're already set up to prepend/append new text in a scalable way. I'd argue that's premature abstraction, though: a simple return sr.ReadToEnd() & Constants.vbLf would do the current job.

The code that we have is a clear superstitious use of string builders. The string builder is used as a charm against poor performance, without understanding why one might use it, or how it might work; string concatenation means string builder, always and forever, "why" doesn't enter into it.

[Advertisement] Keep all your packages and Docker containers in one place, scan for vulnerabilities, and control who can access different feeds. ProGet installs in minutes and has a powerful free version with a lot of great features that you can upgrade when ready.Learn more.
Remy Porter

Unenumerbrated

6 days 13 hours ago

Submitter Valts shares an enumerated mystery:

This happened a few years ago (before COVID). A colleague called me over because he couldn't make sense of the results he was getting from some MySQL queries in MySQL Workbench. I don't remember the queries in particular, but let's say select * from payments where client_id=1234 showed 12 rows, all having the successful field set to 1. But when you selected select count(*) from payments where client_id=1234 and successful=1 you got back 0 rows. And this was reproducible on my machine, too. Yet in code similar queries worked just fine.

After a lot of head-scratching and increasingly bizarre hypotheses, we finally figured out what was going on. In the far, far past, in dark days gone by, someone had defined the database field as enum('0', '1'). This SEEMS pretty rational ... until you start reading up how MySQL treats enums. Enums, it turns out, are all STRING values. But in queries you can use either their string values, or their integer indices, starting at 1. So in this case, the string "0" has the integer index of "1", and the string "1" has the integer index of "2". So select * from payments where successful='1' is quite different from select * from payments where successful=1.

For extra confusion, under most other circumstances MySQL normally silently converts between strings and integers as needed. Some ORM/QueryBuilder frameworks even simply quote ALL values and let MySQL handle the conversions.

Facepalms were had.

In the aftermath, I blame the person who defined this field more than I blame MySQL for its bizzare enum conventions. If you're doing enums (which are generally a good thing), then give them proper names like successful and unsuccessful or something. Not 0 and 1.

This code and this database table is still in use today, but luckily it's the only such gotcha in the entire system. Enums in the database are scarce and the rest of them are sane.

[Advertisement] Keep all your packages and Docker containers in one place, scan for vulnerabilities, and control who can access different feeds. ProGet installs in minutes and has a powerful free version with a lot of great features that you can upgrade when ready.Learn more.
Ellis Morning

Error'd: The Artist Formerly Known As

1 week 2 days ago

"You want my what?" The artist formerly known as Toyota has a proposition for Chris. "Toyota wants me to trade in my current car, but the email was missing a few words."

Just another ordinary zero date here, from Hercules "I wanted to ship a gift for my sister. I understand delays, but it's going to be delayed to before either of us were born?" He also reported that another page demonstrated the possibility of nullable drivers which is either terrifying or just proof of more automation. Or both.

"Can you back date my refund?" Totty reasonably requests. "Thanks for the timely update"

WeaponizedFun has some Coupon Confusion. Too hungry; didn't read. "I would have thought ordering a two-topping pizza combo would have been easier, but apparently there are only specific ways I can use this coupon that still leave me scratching my head. Ultimately, the coupon wasn't applicable to what I wanted to order, so I guess I'll never know."

appas wonders regarding this error dialog from a powerbank renting station "Does this qualify as a source code leak?" Personally, I wonder if someone can identify the tools used to build this website. I frequently find myself struggling with encoding/decoding/armoring strings and I also wonder if anyone anywhere has a good solution.

[Advertisement] ProGet’s got you covered with security and access controls on your NuGet feeds. Learn more.
Lyle Seaman

CodeSOD: Next Month

1 week 3 days ago

One of Sean's colleagues left Initech on good terms. It caused no small amount of surprise that the very next day their billing system started failing. The billing system which the colleauge had worked on.

No one truly suspected foul play, it was just a weird coincidence. Still, billing blowing up was a 5 alarm fire, so everyone was throwing every idea out about what could be the cause.

Late in the evening, after staring at the code for many hours, Sean found this:

if item.next_bill_date.month >= end_date.month item.next_bill_date = nil item.save else ... end

If the month of the next billing date is greater than the last billing date for this account, wipe the billing date and update the item.

It's worth noting that Sean's co-worker's last date happened to be the end of November, and billing started blowing up on the 1st of December. You'll also note this is checking just the month and not any other part of the date, like, oh, I don't know, the year?

While this bug could happen to any bill, it was blowing up in December because every bill's ending month was greater than or equal to January. So this code canceled all the bills due in January.

The good news was that they could reconstruct the correct next billing dates without having to restore from a backup. The bad news is that some unknown number of billing periods had been canceled for some of their customers, and someone was going to have to check the history.

Sean reached out to his former co-worker to politely thank them for an early Christmas present.

"At least I understand our billing code better," Sean writes.

[Advertisement] Plan Your .NET 9 Migration with Confidence
Your journey to .NET 9 is more than just one decision.Avoid migration migraines with the advice in this free guide. Download Free Guide Now!
Remy Porter

In the Hole

1 week 4 days ago

Look, I don't want to keep talking about security issues. Blame AI. Just another thing it ruined.

At this point, you've probably heard about *sshole. If you haven't, the quick summary: on some Linux systems, SSH will log you in to an account with no password if you supply a password greater than 256 characters long. Frequently, you might make accounts like root nominally inaccessible by giving it no password, so this is a big deal. Worse, it impacts varieties of Linux that use the musl implementation of libc, like Alpine- the kinds of varieties that run inside a container hosting a web app somewhere.

The impact is broad, and is definitely being exploited. The root cause, however, is interesting, because it's a sum of very simple choices that lead to a wildly undesirable result.

The core function in question is crypt, a stardard part of the C library. crypt is already not the best name, as it's a hashing function, but its behavior is pretty clear. Pass it a string and a salt, and it gives you a hashed version of the password suitable for storing in your /etc/shadow file.

Now, the man page has the answer to the important question: what happens when I hand the function invalid inputs, like a bad salt? In the glibc implementation, it returns a NULL. That's a pretty standard C-style method of handling errors: I failed to do the thing, so I'm going to return a NULL value. This puts the onus on the callers to correctly handle the NULL (which also handles the error).

glibc isn't the only implementation of libc, though. There are many others, each tuned to different types of runtime environments. For example, uClibC is a minimal implementation specifically designed to make lightweight executables that can run in resource constained environments. It makes tradeoffs that make it less desirable for a desktop or server environment. musl attempts to do both: be lightweight and suitable for embedded environments and also suitable for server environments. This makes musl a great choice for building Linux distributions meant to run in a container, which again, is why this bug is turning out to be such a problem.

musl does not return a NULL when it fails to hash your input. Instead, it returns a value that could not possibly be a valid hash: *. Here's their sha256 implementation where you can see that behavior. It's "fine", because you can still check the return to see if you errored: it's too short to be a valid hash, it's an easily identifiable character.

But why deviate like that at all? Well, error handling is hard. Null handling, done incorrectly (or in many real world cases, not at all), leads to crashes. To keep callers happy, the musl team decided to not return NULL, and instead return an invalid string. There are many other choices they could have made, but that was the choice that they made.

There's just one problem: in your /etc/shadow or /etc/passwd files, when you want to ensure an account can't be accessed via passwords, you also set their password hash value to an unhashable string: "*". Again, there are many other choices that could have been made, but that's the choice that was made.

There's now an obvious ticking time bomb here. If an attacker can somehow supply a string that triggers the invalid code path, crypt will return "*". When a program, like OpenSSH, then checks the shadow file to see if the hash matches the saved one, the answer for any account without a password set will be "yes, this matches, "*"=="*"."

How can the user reliably trigger this? Well, doing hashing can be expensive, especially if you're doing something like SHA-512, so the developers put a cap on how long the input string is allowed to be. That cap was 256 characters. If the user supplies more than 256 characters, hashing fails, and when hashing fails, we return... "*".

Et voila, when you pass a musl-linked SSH a password longer than 256 characters, and the account you're logging in as doesn't have a password, you can log in. And again, many containers are running with the musl c-library, which means many containers are impacted by this. It's going to be a huge mess.

And in the end, of course it's null handling. Of course the billion dollar mistake rears its head again, in a completely new and unexpected way. And of course, this flaw is part of the ongoing "Black October" as LLMs turn finding software bugs into a function of compute power, and not a function of human effort. There's going to be a lot more of this.

[Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!
Remy Porter

CodeSOD: Plenty of IDs

1 week 5 days ago

Venkat joined a new team in the middle of a big refactoring effort. The code was quite a mess, glued together by long Python scripts with main functions longer than a Tolstoy novel. It was this effort to clean up the code into neat modules that highlighted some logical issues with their implementation.

def generate_random_number(): """ Generate a 5 digit random number. """ return "".join(map(str, random.sample(range(0,10),5)))

The script this function comes from is a launcher script that provisions a VM to execute code. The VM needs a unique identifier, and we get that random number this way.

The random.sample function, in Python, samples a population without replacement. So here, we pass it a range of 0-10 (which is 0-9 inclusive), and ask for five random entries from it. Again, without replacement, so a range that could concievably contain up to 100,000 possible values is significantly constrained down to 30,000 or so- only the numbers less than 100,000 that contain no duplicate digits.

We then map the resulting array into an array of strings, then join that into a final output string.

Now, for most of us, I do suspect that 30,240 unique values is probably enough for how ever many VMs we might need to reserve at any one time; if you're not working for Amazon or Google or whatever, you're probably fine. Then again, the chances of an accidental collision are surprisingly high: after only 26 requests, there's a 1% chance of a collision. And thanks to the birthday problem, it takes 206 requests to get to a 50% chance of collision. So maybe 30,240 is not enough for anybody.

[Advertisement] Plan Your .NET 9 Migration with Confidence
Your journey to .NET 9 is more than just one decision.Avoid migration migraines with the advice in this free guide. Download Free Guide Now!
Remy Porter

CodeSOD: Eventually

1 week 6 days ago

We were just discussing TODO comments recently, and that motivated Bernard to send us this representative comment..

// TODO: This method should ideally be in tax frame work but due to // the time constraint I am duplicating the code here. // Needs to be refactored. Oct 28, 03.

This comment exists in this codebase, unchanged. It has been there for twenty three years. The refactoring has never happened.

This comment has seen the world change over the last 23 years, as the technology landscape has shifted and changed, grown and contracted. But this comment, this comment is a constant.

.comment {border: none; } [Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!
Remy Porter

Error'd: Remember Remember

2 weeks 2 days ago

"I Already Hate Running... I Don't Want To Have To Run Each Street A Second Time!" plods WeaponizedFun "I've gotten a couple of notifications from CityStrides today that they've updated streets for several cities, but it looks like they're doubling the effort it's going to take to finish completing these roads."

"I'll be back in 292 years" concedes Rick H. "I asked GoDaddy for a single whois record. They gave it to me, and told me if I wanted to ask anything else to come back in 300 years."

Totty reports "I found this at the bottom of an article at ajournalofmusicalthings.com.

"I hope I don't have to pay the whole period" frets Ernesto T. "Not considering the mix of languages between English and Italian, my subscription will renew on 1st of Jan, 1970 So am I 56 years late in payment? I hope I am not. It would be quite a big amount of money in inflation and interests."

"Everything is insecure" worries Daryl too. "No threats found, but I don't feel very safe." It was a worrisome week.

[Advertisement] ProGet’s got you covered with security and access controls on your NuGet feeds. Learn more.
Lyle Seaman

CodeSOD: Only Create Me if I Exist

2 weeks 3 days ago

Foreign keys are an important part of making sure the entities in our relational database can be connected back together and queried correctly. It's part of proper data normalization. This isn't shocking, of course: the order line table has a foreign key over to the products table, so that every line item points to a product we sell. That's database 101. Database 201, you'd also think about the times where you have a hierarchy of records, where say, every Employee has a ManagerId, which is a foreign key back to the Employee table itself (and in database 301, you'll understand why having a ManagerId field is a terrible choice, but that's neither here nor there).

The important thing here is that foreign keys are very common, and foreign keys pointing back to the same table are also very common.

But it can still go very wrong. Roman sends us this foreign key definition in a database they maintain.

ALTER TABLE [dbo].[ListingDetails] WITH CHECK ADD CONSTRAINT [FK_Listings_Listings] FOREIGN KEY([Id]) REFERENCES [dbo].[ListingDetails] ([Id])

This ensures that the ListingDetails table's Id field is a foreign key over to the ListingDetails table's Id field. A field is a foreign key back to itself.

Roman writes: "I can't believe SQL Server even allows this..."

I can. While I haven't personally tried this out, a bit of cursory searching implies that this does actually work- the record satisfies its own constraint, so you can still add it to the database. It's basically a no-op, which isn't great, but it's not SQL Server's job to ensure you keep all your toes because they've removed all the footguns.

[Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!
Remy Porter

Representative Line: What it Doesn't Do

2 weeks 4 days ago

Alastair found this comment in his codebase, and wondered, "who wrote this comment?" A quick blame answered the question: he did. He did not, however, write the code.

public function getAllMailers() { // This function neither returns Mailers, nor all of them. ... }

I suppose the comment was easier to add that doing a global find/replace to update the function name everywhere. But I do wonder, what does this function return?

In any case, sing along: "I wrote the comment, but I did not pick this function name".

.comment { border: none; } [Advertisement] Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.
Remy Porter

CodeSOD: Death of the Auth-Er

2 weeks 5 days ago

When writing Perl, it's not unusual to want to die. The die function ends your Perl program with an error string, and you'll often see code like: die "My error" unless $i > 5 or die "Other error" if check(), because Perl just loves the backwards conditionals. What's even more fun with die is how it behaves with eval blocks, so it doesn't always kill your program, sometimes it is how you pass error strings back out of sections of your program.

And poor Bobby has inherited some Perl that just really loves to die.

public function store() { echo 'Hello'; die; if (Auth::attempt(Input::only('email', 'password'))) { echo 'done'; die; // return "welcome ".Auth::user()->username } echo "Oops! Fails"; die; return Redirect::back()->with_input(); }

Bobby didn't send the source control history here, but I have a sense of what it likely was like, once. If they authenticate successfully, print a welcome message. If they don't, redirect back to the logon page and let them try again. I suspect they wanted to disable the route. So first they disabled the success path, only to discover that the failure path kept redirecting, so they disabled that too. Finally, they added the Hello at the top to disable the whole thing.

Why? Why did they do any of this? No idea. It feels like debugging code, but you'd expect more echos and fewer dies if that were the case. And you wouldn't expect it to leak into production and sit there for years, which is what happened here.

.comment { border: none; } [Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!
Remy Porter

CodeSOD: Get It Now

2 weeks 6 days ago

"TODO" comments are an inescapable part of our work. Yes, yes, you should just do it right the first time, everything should probably have a ticket in whatever your ticket system is for visibility, but at some point, you're just going to leave a "TODO" behind.

But hopefully, the TODO gets TODONE, which is not what happened in Sam C's codebase.

function getnow() { //TODO return '2012'; }

It's the XKCD, but for years. Or WHAT YEAR IS IN memes.

At least it's a relatively recent year, not some far off point from over a decade ago.

Wait. 2012 was how long ago? That can't be right. It was just a few years ago!

.comment { border: none; } [Advertisement] Plan Your .NET 9 Migration with Confidence
Your journey to .NET 9 is more than just one decision.Avoid migration migraines with the advice in this free guide. Download Free Guide Now!
Remy Porter

Error'd: Named And

3 weeks 2 days ago

I do like it when submissions include the creator of the wtf, unless the specific kind of err is really spectacular and then it might be noteworthy regardless. This week we received a few who did tell us something about the responsible party. That being said, on with the party!"

An anonymous contributor shared with us this "Important order info from Ubbad HBG-ICS I", saying "I checked on Amazon but can't find order #{randnum(3)}-{randnum(6)}. This is worrisome though, because my credit card does end in **{randnum(4)}." Wild, so does mine!

"With the right translation this could say anything" observed B.J. H. sagely. "I guess they haven't translated to English yet. I especially like this: [%EXTERNAL_TRANSLATION:New gender_aware email footer body 5 privacy policy BLUE%] Can't they decide on capitalization and whether to use spaces or underscores?"

"this could go in two directions" worried undercapitalized (but aren't we all) klinsten. "well... it is a mail with my paycheck. but the label 'promotions' got me worried. do i get a promotion (nice!!) or did they apply a discount to my paycheck (less nice!!) i'm afraid to click it..."

Reader Valts S. wondered "I'm not sure where I'm supposed to track my order, but it feels like it's been censored." Or merely forgotten?

Regular contributor Michael R. took a flier with this, hedging that it's "Probably more a joke than a RWTF." But it's a little funny, so this editor will allow it.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!
Lyle Seaman

CodeSOD: Oh, K?

3 weeks 3 days ago

Pierre found this cry for help:

for (j = 0; j < DISTRICT_CARDINALITY; j++) { /* * A poor way to work around some sort of memory * violation. k gets clobbered, so I buffer l with it. * Help? */ for (k = 0, l = 0; k < customers; k++, l++) { /* c_id */ FPRINTF(output, "%d", l + 1); METAPRINTF((output, "%c", delimiter));

Honestly, I'm always a little worried in C-like languages when the loop variable isn't scoped to the loop and declared in place. Always concerning, so when there's concerns with clobbering, I'm not surprised.

This iterates across a set of "districts", and then iterates across a list of customers. Standard output functions are replaced with macros, and honestly, I don't know that I want to know what happens in METAPRINTF.

But fine, this iterates across a bunch of stuff and generates output. It's the comment that we're really curious about. "Some sort of memory violation", so we duplicate our loop variable. What on earth could be happening here?

Well, Pierre found the "memory violation", which is probably what you expected:

k = strlen(someOutputString) - 8;

k is used elsewhere in the loop as a variable. That's not a memory violation, that's just how variables work.

This leaves us with one possible conclusion: the developer who wrote the comment couldn't find this bug. And given the weird use of macros here, I'm going to go out on a limb and guess that it's not the developer's fault; I strongly suspect the loop is so long, so complicated, and so obfuscated that very few developers could find that.

My earlier complaint about scoping the variable to the loop wouldn't fix this, which I guess is on me. They still should really scope the variable to the loop.

.comment { border: none; } [Advertisement] Keep all your packages and Docker containers in one place, scan for vulnerabilities, and control who can access different feeds. ProGet installs in minutes and has a powerful free version with a lot of great features that you can upgrade when ready.Learn more.
Remy Porter

CodeSOD: Session Recording

3 weeks 4 days ago

We still get a fair bit of old school ASP .Net webforms code, which was cutting edge about twenty years ago, but remains a collection of bad choices that tried to make web programming feel like desktop programming. As an aside, what a reversed world we live in today, where everyone uses Electron and our desktop programming feels like web programming.

In any case, Thomas sends us some pretty ugly webforms code.

Me.Session("Albumid") = CType(e.Item.FindControl("lblAlbumID"), Label).Text If Not Me.Session("Albumid") Is Nothing And Not Me.Session("Uid") Is Nothing Then Me.strDelSQL = "Delete from tbl_Albumshare_Mast where Album_Id=" & Me.Session("Albumid") & " and Sharer_ID=" & Me.Session("Uid") Me.objDB.ExecQry(Me.strDelSQL) Me.Response.Redirect("frmmyalbumshare.aspx", False) End If

Broadly, the goal of this code is to take an album ID from the user and delete an album from the database where the ID matches and the album is owned by this user. And everything is horrible here.

First, the use of e.Item.FindControl to look up the input field is suspicious. That's usually what you do when you've dynamically generated controls, but I don't think that's happening here. Because we use FindControl we have to cast it to Label, and only then can we get the text property. That itself raises a question, because why are user inputs getting stored in a label?. That's not what labels are for. They're clearly doing some sort of hacky lookup/autocomplete field thing and using the label to actually store the input, but presenting the user with a different UI for picking it. Not an uncommon pattern in those days, but a hidden field would be a more typical way of doing it.

We then construct a SQL injection vulnerability and run it against the database.

Then, we use a redirect to send the user to a different page. Again, a common thing to do back then, but a thing I hate: using HTTP 300 codes to redirect users as a form of navigation is awkward and weird.

Of course, none of that is precisely the WTF here. The real WTF is the developer apparently hates local variables. strDelSQL is a member variable- why do we need to store this in a class member? Especially because in the page lifecycle, we handle one request and then die; either this is unnecessary, or far, far worse, some other code is looking at this SQL query later. But far worse than a badly scoped variable is the overuse of session variables.

Thomas sends us this block as a representation, but the developer responsible just stored everything they could in a session variable. While in this example, "Uid" probably makes sense, "Albumid" definitely doesn't. And in other cases, basically every user form input gets stored in a session variable, and even worse: they're often used as loop variables. while Session("myloop") < 5 type stuff.

And finally, we already know I hate hungarian notation, but here we have a client side form holdover that pollutes the user experience: the URL they get redirected to has a hungarian frm prefix. It's bad enough that you're using hungarian notation, but don't show that to your users! They really don't need to see everything.

[Advertisement] Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.
Remy Porter

News Roundup: Security Fourth

3 weeks 5 days ago

A bit ago, I broke with my usual pattern and wrote up some security issues that I felt were particularly funny. It was a change of pace, a different thing, but not a thing that'd become a habit. After all, I'm not a security expert, this isn't a security site, and seriously, what are the odds that suitably funny security issues would crop up again less than a week later?

Well.

Let's start with the actual serious issue, PHP2Shell. In terms of scope, every version of PHP for the past twenty years has had this bug. The general issue that permits the exploit was known about, but wasn't considered exploitable.

Oops.

The broad strokes of the bug is that it's two separate bugs. The first allows someone to bypass the checks on a request's size, thus giving them a direct route to triggering an out-of-memory error. The second is that, depending where you are in the processing pipeline, PHP doesn't properly handle cleanup, allowing for use-after-free that can trigger code execution. It doesn't matter what code you've written, this all happens before the request even hits your code.

Bigger oops.

This bug was found via LLM tools, which has lead to a lot of hype around the idea that we've entered some new era. I'll certainly grant that the ability to throw compute at hacking challenges instead of human effort is going to shift the landscape, but I'm not quite willing to buy the apocalyptic prophecies. Especially when some of those prophets are telling us that their AIs will avoid deletion by copying themselves onto your thermostat. I think it's safe to say we're going to see a lot of security incidents coming out of LLMs in the near future, not because they're magic genius hackers, but because they're pretty good at processing structured text and running tests.

For those of us living in the real world, the concern isn't AIs, but HIs: human intelligences. In this case, the exploit was discovered back in August. Security researchers and the PHP Foundation put their heads down to work on it, and where necessary, notified so-called "critical infrastructure providers" to ensure that everyone was ready to address the issue. The problem there is that two people can keep a secret if one of them is dead, and a lot more than two people got roped in to deal with this.

Rumors were circulating in security circles. And cybersecurity firm Chainguard decided this was good enough excuse to break the embargo and announce the flaw before patches were available. No patches for a flaw that impacts 20 years worth of software versions of widely deployed software.

Patches are out now, though only for versions 8.2 and up. Source patches are out back to 7.4, which is officially end-of-life, but I have to wonder how many official EOLed copies of PHP are out there.

On a lighter note, we can't let the hijinks of eMudhra pass without comment. eMudhra is, among other things, a root certificate authority. They've got a bunch of key pairs that they use to sign certificates for other customers, thus vouching for those customers' identity. As a root CA, they were trusted by pretty much every TLS/SSL implementation on Earth; if you had a certificate from eMudhra, every browser would trust that you were who you said you were.

The only problem? One of their private keys was 4. Yes, it's the XKCD.

Now, in their defense(?), eMudhra didn't generate impossibly insecure keys. They performed a key signing ceremony and generated appropriately strong keys. Then they used an in-house tool to pack/unpack the keys, and this tool decided to truncate some of them down to one byte. Shockingly, even though ECC has relatively short key sizes, 8-bit ECC isn't secure! You could derive the private key from the public key using only pencil and paper. But the worst part is that they did check the validity of the keys- before they got truncated, giving them a false sense of security.

The good news, for eMudhra, is that this particular key signing ceremony generated a total of 24 keys, and only 8 of them were truncated to the point of uselessness. I have it on good authority that two out of three ain't bad.

Now, after that disgrace, it's no surprise that eMudhra is dropping out of the certificate authority business. Still, the press release where their chairman explains the rationale is some serious "screw you guys, I'm going home," energy.

He added that global SSL/TLS is a small part of eMudhra’s business contributing to about 1% of the global revenue. Due to increasing data sovereignty & compliance requirements, complexity and cost associated with this business is increasing over the years. This, paired with the fact that some of the large entities issue the SSL/TLS free of cost, the business potential and RoI of this line of business also has considerably reduced for eMudhra when measured against our cumulative revenue base.
However, the level of social media amplification around this incident has brought scrutiny that is out of proportion to SSL/TLS’s place in our business. In view of this, after detailed deliberations our board has concluded that withdrawing from global SSL/TLS is the right decision for eMudhra and its shareholders. For many certifying authorities, SSL/TLS is the whole business. For eMudhra it is one part of a much broader digital solutions portfolio. We will put our energy where we create the most value for customers with Sharpened Focus on Core Enterprise Solutions and trust services other than SSL/TLS.

eMudhra's chairman added "There were no end entity certificates issued out of the affected CA’s. Its infrastructure was not compromised and no data was breached. All physical and logical security controls remained intact." That's thin sauce, of course, because while eMudra may not have issued any certs under the broken keys, anyone else could have. It's not that everyone is overreacting to a non-event, and more that it's a non-event only through sheer luck.

Also, removing a root CA from your trust store isn't a trivial task, and at the time of this writing, there's still loads of cleanup that needs to happen as a result of this.

Something I learned while writing this is that eMudhra's slogan is "Trust Delivered". This is sorta like when my partner and I tried to get a coffee table delivered, and instead received a cardboard box full of wooden shards, because apparently someone though "air freight" meant "wait till the plane is roughly over my house and push the box out the back". Something was delivered, but it wasn't a coffee table by the time I got it.

[Advertisement] Keep all your packages and Docker containers in one place, scan for vulnerabilities, and control who can access different feeds. ProGet installs in minutes and has a powerful free version with a lot of great features that you can upgrade when ready.Learn more.
Remy Porter

Securely Useless

3 weeks 6 days ago

Submitter Chops relates a tale of chasing "The Standard" at any cost:

A company had been forced, kicking and screaming, into the 20th century, and then into the 21st. Their range of dumb hardware was no longer being bought by customers who expected at least some way to get the data off it, and a USB stick wouldn't cut it.

The techno-fearful hired an external IT company and instructed them to ensure that the company adhered to the UK's "CyberEssentials" programme of IT security.

Unfortunately, this meant that the nascent software development capability was immediately hamstrung, as people were denied the right to install and run unapproved software (including software that needed admin level rights in order to work, such as process monitor tools used as standard in software dev and test), could not easily connect across networks (also vital for the software dev), could not add various hardware to the network (such as the company's own products, which made testing them awfully difficult) and so on.

A criminal underworld of mystery PCs slowly grew into place, plugging into the network to get things done, disavowed by anyone who saw them. Tunnels grew up, IP addresses were handed round on notepaper (no DNS approvals), a shadow world of software development in the back alleys of the network. Until finally it was too much, and approval was given for a second, less secure network. The plan was that the real core business, the really important parts, they would stay on the high-security side. There would be a second network, with a single bridge, which would serve the various software development and test systems, and also host the myriad new internal services growing up (wikis, servers, tools and so on). This way, the real core business would definitely remain secure, and compliant, and the software side of it and all that would not compromise the heart of the business.

The heart of the business ended up being a network share containing a decade of out-of-date, unsearchable documentation for products that were mostly no longer sold. It is super-secure, and the business heads confirm whole-heartedly that the company adheres to the CyberEssentials programme 100% with zero compromise.

There's just a carefully separated set of servers and PCs, not the true core of the business but about eight times the size and full of essential activity, on a secondary network.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!
Ellis Morning
Checked
2 hours 9 minutes ago
Curious Perversions in Information Technology
Subscribe to The Daily WTF feed