- Feature Articles
-
CodeSOD
- Most Recent Articles
- Building a Line
- Next Month
- Plenty of IDs
- Eventually
- Only Create Me if I Exist
- Death of the Auth-Er
- Get It Now
- Oh, K?
- Error'd
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
My first job decades ago where I came in contact with asp.net was literally an vb.net webform app written like this by a student.
No transactional security and the whole thing was a big SQL injection pile of garbage (which a nice simple word for every dark pattern, bad practice and security snafu imaginable combined).
And no, it was an unfixable mess that was core to business operations, so I touched it up as much as possible and otherwise stayed away from it. In the end it was fun growing from 1.0 into the 2.0 era, but oh man, thinking back this gig was the one I learnt the most of what not to do for sure.
Admin
Yeah, I know this shop. For some reason, they don't have the infamous "'); drop database" album in store.... I've tried to find it several times. It's by "Robert'); drop TABLE Students;--"
Admin
Me.Run("away")
Admin
Additional to what Remy wrote, I dislike the construction If Not Me.Session("Albumid") Is Nothing And Not Me.Session("Uid") Is Nothing Then
If you want to catch a or b being Nothing(void/None/...), go for
if a is None or b is None: return
Short and easy to read, safe because the "or" short-circuits, and you save one layer of indentation.
Admin
"If Not Me Is Nothing" -- from the programming language brought to you by Ali G.
(OK, working in a COBOL environment I shouldn't really criticise, but I'm going to anyway)
Admin
This is VB.Net. "Or" doesn't short-circuits due to backwards compatibilty with VB. VB.Net's "OrElse" is the short-circuiting operator.
Admin
Response.Redirect is unfortunately necessary in WebForms. The big sins of WebForms is that it combines navigation and action. This results in situations where application logic requires navigation and action - and that's where Response.Redirect comes into play.
My personal pet peeve with Response.Redirect is that to preserve backwards compatibility with Classic ASP behavior, Response.Redirect does its thing by throwing an exception.
Admin
Of course there is an even worse option - server.transfer. This chains to the back end logic for the page you specify and sends it without a redirect so the URL the user sees on the browser is not the page that was executed.
Admin
I remember some of good old WebForms. I think the paradigm was actually fine, if they only had the foresight to make it work more like modern React + backend webservices. But I digress.
What I wanted to say is - Labels don't post data back. That would be a TextBox or some sort of Input. If they're taking the ID out of the label, that means that they put it in there shortly before, in the processing of the same request. Which would very much follow the theme here. Or... they relied on the infamous ViewState. That can optionally be encrypted, which would at least plug the SQL Injection vulnerability, but I really doubt they had the foresight to turn that on....
Admin
I assume they store all the variables in Session because they started using Application and weird things happened.
Admin
... and here I am thinking "what the heck is Electron?" Turns out it's chromium package with Node.js, which is more along the lines of what I thought everyone was programming in these days.
Admin
Fortunately (?) for me (or, maybe, fortunately for the rest of the world), I do not program in that sort of [REDACTED]. C or C++ directly on (or in)(1) FreeBSD.
(1) "On" for userland services, "in" for deep-juju stuff in the kernel.
Admin
Yeah, Electron is basically hosting your browser app in a desktop like container. Good examples are MS Teams or Discord. It's basically the most wasteful way to make a desktop app but it's the cheapest one, because in the end you just have to maintain a web app and hope people won't stone you for the horrible UX on desktop.
Admin
I found Server.Transfer does have some value... for an app's generic "error" page (especially as I hate errors that redirect you... among which there is none I hate more than redirecting 404 errors, that change the address bar so you can't see the URL that was wrong).
Admin
Don't get me started on
If Not x Is Nothing.IsNothas existed since VB 2005, as far back as .NET Framework 2.0! Unless you're doing webforms in .NET Framework 1.x (which you really shouldn't), there is not excuse not to use it.Admin
TICKET ON DID NOT PASS RESUME NEXT.
Admin
Reading the post and code, I can't help but wonder if the Label hack is some sort of misplaced way of doing something that should be done with a 'hidden'-type form field.
Admin
I really hate this argument. You can save lots of layers of indentation by not using indentation at all to show the structure of your code. Whatever the arguments are for bailing out early, disguising the complexity of your (which is what this argument amounts to) is not one of them.
Admin
How would that prevent the injection vulnerability when the SQL is being built via ye olde string concatenation after being received?
Admin
Would condoms protect you if you were doing the deed in Chernobyl? Still makes sense to wear them.
Admin
Hello, yes, this is Doctor Johnny Holzkopf: To treat stupid, take 5 Albumid forte in the morning, and if stupid persists, take further 2 Albumid. If it doesn't get better, FORMAT C: or RESUME NEXT.
Admin
But it also makes way more sense to construct queries properly. It's still being built by simple concatenation so adding encryption to the request, while fine, doesn't change the fact that the SQL injection vulnerability still exists.
Admin
Naturally. My point is simply that I find it all too easy to harden one part of your pipeline and end there in the mistaken belief that the other parts won't ever be reused abused. I prefer to apply security at both ends for that reason.