Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 16, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 16, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 16, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 16, 2025

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025

      Minecraft licensing robbed us of this controversial NFL schedule release video

      May 16, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      The power of generators

      May 16, 2025
      Recent

      The power of generators

      May 16, 2025

      Simplify Factory Associations with Laravel’s UseFactory Attribute

      May 16, 2025

      This Week in Laravel: React Native, PhpStorm Junie, and more

      May 16, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025
      Recent

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CodeSOD: A Secure Item

    CodeSOD: A Secure Item

    February 27, 2025

    Kirill writes:

    I’ve worked in this small company for a year, and on a daily basis I’ve come across things that make my eyes sink back into their sockets in fear, but mostly I’ve been too busy fixing them to post anything. It being my last day however, here’s a classic

    We’ll take this one in parts. First, every element of the UI the user can navigate to is marked with an enum, defined thus:

    enum UiItem
    { SectionA, SectionB, SectionC,...SectionG }
    

    These names are not anonymized, so already I hate it. But it’s the next enum that starts my skin crawling:

    enum SecurityUiItem
    {
      SectionA = UiItem.SectionA,
      SectionB = UiItem.SectionB,
      ...
      SectionG = UiItem.SectionG
    }
    

    A SecurityUiItem is a different type, but the values are identical to UiItem.

    These enums are used when trying to evaluate role-based permissions for access, and that code looks like this:

    if ((currentAccess.ContainsKey(SecurityUiItem.SectionA) && currentAccess[SecurityUiItem.SectionA] != AccessLevel.NoAccess))
            return UiItem.SectionA;
    else if (!currentAccess.ContainsKey(SecurityUiItem.SectionB)
            || (currentAccess.ContainsKey(SecurityUiItem.SectionB) && currentAccess[SecurityUiItem.SectionB] != AccessLevel.NoAccess))
            return UiItem.SectionB;
    else if (!currentAccess.ContainsKey(SecurityUiItem.SectionC)
            || (currentAccess.ContainsKey(SecurityUiItem.SectionC) && currentAccess[SecurityUiItem.SectionC] != AccessLevel.NoAccess))
            return UiItem.SectionC;
    .....
    else if (!currentAccess.ContainsKey(SecurityUiItem.SectionG)
            || (currentAccess.ContainsKey(SecurityUiItem.SectionG) && currentAccess[SecurityUiItem.SectionG] != AccessLevel.NoAccess))
            return UiItem.SectionG;
    else
            return UiItem.Unknown;
    

    Honestly, I don’t hate the idea of having one data type representing the actual UI objects and a separate data type which represents permissions, and having a function which can map between these two things. But this is a perfect example of a good idea executed poorly.

    I also have to wonder about the fall-through pattern. If I have access to SectionA, I only seem to get SectionA out of this function. Are these permissions hierarchical? I have no idea, but I suspect there’s a WTF underpinning this whole thing.

    Congratulations on Kirill’s last day.

    [Advertisement] Picking up NuGet is easy. Getting good at it takes time. Download our guide to learn the best practice of NuGet for the Enterprise.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleFOSS Weekly #25.09: Modern Terminals, RSS Matter, Linux Gaming Tested in 2025 and More
    Next Article ANDI Accessibility Testing Tool Tutorial

    Related Posts

    News & Updates

    Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

    May 16, 2025
    News & Updates

    Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

    May 16, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    Salesforce CEO Marc Benioff says Microsoft “repackaged OpenAI and dropped it into Excel” — Customers barely use Copilot, and that’s when they don’t have a ChatGPT license

    News & Updates

    Last Week in AI #265: FSD comes out of beta, Israel’s AI system that targets Hamas, Amazon ditches “Just Walk Out,” OpenAI’s artist in residence, and more!

    Artificial Intelligence

    Samsung MagicINFO 9-servers doelwit van botnet, update niet beschikbaar

    Security

    Tencent AI Researchers Introduce Hunyuan-T1: A Mamba-Powered Ultra-Large Language Model Redefining Deep Reasoning, Contextual Efficiency, and Human-Centric Reinforcement Learning

    Machine Learning
    GetResponse

    Highlights

    Apache ActiveMQ Vulnerability Allows Remote Attackers to Execute Arbitrary Code

    May 1, 2025

    Apache ActiveMQ Vulnerability Allows Remote Attackers to Execute Arbitrary Code

    A critical security vulnerability (CVE-2025-29953) in Apache ActiveMQ’s NMS OpenWire Client has been disclosed, enabling remote attackers to execute arbitrary code on vulnerable systems.
    The flaw, roo …
    Read more

    Published Date:
    May 01, 2025 (21 minutes ago)

    Vulnerabilities has been mentioned in this article.

    CVE-2025-29953

    Visual EXPLAIN for MySQL and Laravel

    July 27, 2024

    How to Build Slim and Fast Docker Images with Multi-Stage Builds

    May 14, 2025

    NVDA Guide: Essential Tips for Accessibility Success

    March 16, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.