Zum Hauptinhalt springen
Intelligence View
⚡ tsecurity.de Intelligence

CodeSOD: When False is True

Lillith was integrating some new tools into an existing Ruby on Rails API. The existing API allowed you to send a dry_run flag along with the request, so that…

Beitrag
0
Seite
0
↗ Quelle (thedailywtf.com)
Quelle & Fakten · 2 Min. Lesezeit
Quelle: thedailywtf.com
Rubrik: Programación segura

Lillith was integrating some new tools into an existing Ruby on Rails API. The existing API allowed you to send a dry_run flag along with the request, so that you could have the service calculate its changes without applying them.


The problem was, the new tool Lillith was integrating could send, in the body of the request, {"dry_run": false}, but the service would see it as true. Consistently.


The helper method which checked for "true" parameters looked like this:


def param_true?(param_name)
param_value = params[param_name]
params.key?(param_name) && (!param_value || param_value.to_s.downcase == 'true')
end

The purpose of this function is to handle stringy or nil inputs gracefully. And there's one thing I can say about the function: it will always identify a true value correctly. If your false value is a string, "false", it also works. But that pesky !param_value mean that any actual boolean false value will be seen as true.


This function has been in wide use through the application. Lillith's best guess is that up to this point, no one had set the dry run flag on anything but GET requests, where everything was strings. On POST/PATCH/PUT requests, where the data was passed in the body as JSON, it got parsed into actual boolean values, and thus failed.


That's the WTF, certainly, that this function was lurking and waiting to cause this confusion. But the annoying thing in this function is that it fetches the value from the associative array, then calls params.key? to see if the key exists. That's fine, since Ruby just returns a nil if a key doesn't exist, it's just annoying. I hate to see it. This is, admittedly, more of a "me" problem, but I hate it.



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

Social ReaktionenReagiere als Erste:r — dein Feedback zählt!
Informations-Bewertung:
✏️ Information ergänzen
🛡️ Versioniert via CMS-Revisions-Engine (Freigabe-Queue für Gäste)

💬 Debate de la comunidad y comentarios

🌐 Unirse al chat principal

Inicia el debate en el stream de difusión del Social Chat o envía arriba una contribución experta mediante el formulario de ampliación.

Briefing de seguridad Gratis · baja en 1 clic

Intelligence Digest — gratis

Cada día las noticias de seguridad más importantes · baja en cualquier momento

Valoración de la comunidad & prueba social
⭐ Valoración de los lectores
–
Ø / 5.0
Aún no hay valoraciones de lectores
¿Le ha resultado útil este artículo?
0
Dejar una valoración ahora
Valoración detallada (opcional)
Contenido & calidad
Fuente & credibilidad
Actualidad

Clústeres de historias relacionados & fuentes (IA vectorial)

6 Cluster
26 fuentes
Black Friday Oura Ring deals: The best of the deals so far, picked by a wearable-tech expert
Latest from TechRadar hace 23 min.
25 fuentes más
CNEThace 6 añosOur Favorite Blenders of 2026 Are on Sale Ahead of Black Friday CNEThace 27 min.Brighten Up Your Day by Saving 20% Off Flashlights With Olight’s Black Friday Sale CNEThace 19 min.Live: Black Friday Deals Are Here. Shop Expert Picks Across Tech, Everyday Essentials and More at Up to 60% Off Golem.dehace 33 min.Anzeige: Logitech-Tastatur MX Keys S am Black Friday zum Sensationspreis auf Amazon PC-WELThace 45 min.Luminar zum Black Friday: KI-Bildbearbeitung für nur 79,20 Euro Latest from TechRadarhace 1 hThis is the pair of open earbuds to hunt down over Black Friday Latest from TechRadarhace 1 hBest AirPods Black Friday deals: all live savings on AirPods Pro 3 and more Computer Bildhace 1 hPhilips Sonicare DiamondClean 9000 zum Black Friday günstiger netzwelt.dehace 2 hESR startet mit Black-Friday-Rabatten: Diese AirPods-Hüllen lohnen sich jetzt netzwelt.dehace 2 hPlayStation 5 geschenkt: Diese Black-Friday-Aktion legt die Konsole gratis obendrauf netzwelt.dehace 2 h6 Dyson-Staubsauger im Vergleich: Dieser Sauger wird am Black Friday überraschend zum Preis/Leistungssieger netzwelt.dehace 1 hMonitore im Angebot zum Black Friday: Gutes Bild für Office, Gaming und mehr Golem.dehace 1 hAnzeige: Akkuschrauber mit 20 Bits zum Black Friday erstmals unter 50 Euro bei Amazon PC-WELThace 1 hDie günstigsten Handytarife an Black Friday von 10 GB bis Unlimited: Hier lohnt sich ein Wechsel PC-WELThace 1 hBlack Friday 2026 bei LiberNovo: Ergonomische Bürostühle mit bis zu 44 Prozent Rabatt Latest from TechRadarhace 1 hThe best Black Friday robot vacuum deals: Dreame, Shark, Dyson, and Roborock Golem.dehace 1 hAnzeige: Topdon-Starthilfe-Powerbank für Kfz zum Black-Friday-Bestpreis nur rund 85 Euro heise online Newshace 1 hBlack Friday: Die besten Kopfhörer zum Tiefstpreis – Sonos Ace, Nothing & Shokz Latest from Windows Centralhace 1 hDell's Black Friday deals drop major savings on Alienware OLED monitors CNEThace 2 añosMake Every Night Game Night and Save $90 on the Nex Playground With This Black Friday Deal DEV Communityhace 1 hThe app is part of the gadget: 14,000 App Store reviews of 28 device apps before Black Friday Latest from TechRadarhace 2 hBlack Friday tech deals under $100 / £100: Fire TV Sticks, earbuds, coffee machines and more Caschys Bloghace 3 hGoogle One: Black-Friday-Angebot mit bis zu 50 Prozent Rabatt netzwelt.dehace 3 hDem Testsieger ebenbürtig: Zum Black Friday stürzt Xiaomis stärkster E-Scooter im Preis ab Macerkopf.dehace 3 hFotos verbessern mit Aiarty: 52 % Rabatt + Gratisgeschenke zum Black Friday
Artículos similares
🔍 Verwandte News

Auch interessante Nachrichten CodeSOD: When False is True

Thematisch verwandte Begriffe: CodeSOD, When, False, True · 6 Treffer

Laden...

Cargando vídeos ...

Laden...

Cargando artículos ...

Laden...

Cargando vídeos ...

Laden...

Cargando artículos ...

Laden...

Cargando vídeos ...

Laden...

Cargando artículos ...

Laden...

Cargando vídeos ...

Laden...

Cargando artículos ...

Laden...

Cargando vídeos ...

💬 Cargando comentarios…
Desliza para actualizar
Widgets & Topics
Loading widgets…
Nächster Beitrag