Access Control Pitfalls v2


Published on

Access Control is a necessary security control at almost every layer within a web application. This talk will discuss several of the key access control anti-patterns commonly found during website security audits. These access control anti-patterns include hard-coded security policies, lack of horizontal access control, and "fail open" access control mechanisms. In reviewing these and other access control problems, we will discuss and design a positive access control mechanism that is data contextual, activity based, configurable, flexible, and deny-by-default - among other positive design attributes that make up a robust web-based access-control mechanism.

Published in: Technology, Business
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Frank Piessens
  • User Joe can execute ViewReport as a manager specific to DataSet 2314
  • Access Control Pitfalls v2

    1. 1. Access Control Pitfalls and Best Practices © 2013 WhiteHat Security, Inc.
    2. 2. Access Control Best Practices • Build a centralized AuthZ mechanism • Code to the ACTIVITY, not the role • Design AuthZ as a filter • Deny by default, fail securely • Server-side trusted data should drive AuthZ • Be able to change entitlements in real time • Design standardized data contextual AuthZ • Build grouping for users and permissions © 2013 WhiteHat Security, Inc.
    3. 3. Access Control Anti-Patterns • • • • • Hard-coded role checks in application code Lack of centralized access control logic Untrusted data driving access control decisions Access control that is “open by default” Lack of addressing horizontal access control in a standardized way (if at all) • Access control logic that needs to be manually added to every endpoint in code • Access Control that is “sticky” per session • Access Control that requires per-user policy © 2013 WhiteHat Security, Inc
    4. 4. General Access Control Model Action Authentication © 2013 WhiteHat Security, Inc Guard Principal Protected system Authorization
    5. 5. What is Access Control? Authorization is the process where a system determines if a specific user has access to a resource • Feature/Activity: Represents app behavior only • Entitlement/Permission: What a user is actually allowed to do and what data they can access • Principle/User: Who/what you are entitling • Implicit Role: Named permission, user associated – if (user.isRole(“Manager”)); • Explicit Role: Named permission, resource associated – if (user.isAuthorized(“report:view:3324”); © 2013 WhiteHat Security, Inc.
    6. 6. Access Controls Impact • Loss of accountability – Attackers maliciously execute actions as other users – Attackers maliciously execute higher level actions • Disclosure of confidential data – Compromising admin-level accounts often results in access to user’s confidential data • Data tampering – Privilege levels do not distinguish users who can only view data and users permitted to modify data © 2013 WhiteHat Security, Inc.
    7. 7. Attacks on Access Control • Vertical Access Control Attacks – A standard user accessing administration functionality • Horizontal Access Control Attacks – Same role, but accessing another user's private data • Business Logic Access Control Attacks – Abuse of one or more linked activities that collectively realize a business objective © 2013 WhiteHat Security, Inc.
    8. 8. Hard-coded roles © 2013 WhiteHat Security, Inc.
    9. 9. Hard-Coded Roles void editProfile(User u, EditUser eu) { if (u.isManager()) { editUser(eu) } } How do you change the policy of this code? © 2013 WhiteHat Security, Inc. 9
    10. 10. Hard-Coded Roles if ((user.isManager() || user.isAdministrator() || user.isEditor()) && != 1132)) { //execute action } © 2013 WhiteHat Security, Inc. 10
    11. 11. Hard-Coded Roles • Makes “proving” the policy of an application difficult for audit or Q/A purposes • Any time access control policy needs to change, new code need to be pushed • RBAC is often not granular enough • Fragile, easy to make mistakes © 2013 WhiteHat Security, Inc. & BCC Risk Advisory Ltd 11
    12. 12. Order-Specific Operations 12
    13. 13. Order- Specific Operations Imagine the following parameters e Can an attacker control the sequence? Can an attacker abuse this with concurrency? © 2013 WhiteHat Security, Inc. 13
    14. 14. Rarely Depend on Untrusted Data • Avoid trusting request data for access control decisions • Never make access control decisions in JavaScript • Never make authorization decisions based solely on: – hidden fields – cookie values – form parameters – URL parameters – anything else from the request • Never depend on the order of values sent from the client © 2013 WhiteHat Security, Inc. 14
    15. 15. Best practice © 2013 WhiteHat Security, Inc. 15
    16. 16. Best Practice: Centralized AuthZ • Define a centralized access controller – ACLService.isAuthorized(PERMISSION_CONSTANT) – ACLService.assertAuthorized(PERMISSION_CONSTANT) • Access control decisions go through these simple API’s • Centralized logic to drive policy behavior and persistence • May contain data-driven access control policy information © 2013 WhiteHat Security, Inc. 16
    17. 17. Best Practice: Code to the Activity int articleId = request.getInt(“articleId”); if (AC.hasAccess(“article:edit:” + articleId)) { //execute activity } • Code it once, never needs to change again • Implies policy is centralized in some way • Implies policy is persisted in some way • Requires more design/work up front to get right © 2013 WhiteHat Security, Inc. 17
    18. 18. Using a Centralized Access Controller In Presentation Layer if (isAuthorized(Permission.VIEW_LOG_PANEL)) { <h2>Here are the logs</h2> <%=Encoder.forHTMLContent(getRawLogData());%/ > } © 2013 WhiteHat Security, Inc. 18
    19. 19. Using a Centralized Access Controller In Controller try { assertAuthorized(Permission.DELETE_USER); deleteUser(); } catch (Exception e) { //SOUND THE ALARM } © 2013 WhiteHat Security, Inc. 19
    20. 20. SQL Integrated Access Control • Example Feature • This SQL would be vulnerable to tampering select * from messages where messageid = 2356342 • Ensure the owner is referenced in the query! select * from messages where messageid = 2356342 AND messages.message_owner = <userid_from_session> © 2013 WhiteHat Security, Inc. & BCC Risk Advisory Ltd 20
    21. 21. Data Contextual Access Control Data Contextual / Horizontal Access Control API examples: ACLService.isAuthorized(“car:view:321”) ACLService.assertAuthorized(“car:edit:321”) Long form: Is Authorized(user, Perm.EDIT_CAR, Car.class, 321) • Check if the user has the right role in the context of a specific object • Protecting data at the lowest level! © 2013 WhiteHat Security, Inc. & BCC Risk Advisory Ltd 21
    22. 22. Apache SHIRO • Apache Shiro is a powerful and easy to use Java security framework. • Offers developers an intuitive yet comprehensive solution to authentication, authorization, cryptography, and session management. • Built on sound interface-driven design and OO principles. • Enables custom behavior. • Sensible and secure defaults for everything.
    23. 23. Solving Real World Access Control Problems with the Apache Shiro The Problem Web Application needs secure access control mechanism The Solution if ( currentUser.isPermitted( "lightsaber:wield" ) ) {"You may use a lightsaber ring. Use it wisely."); } else {"Sorry, lightsaber rings are for schwartz masters only."); }
    24. 24. Solving Real World Access Control Problems with the Apache Shiro The Problem Web Application needs to secure access to a specific object The Solution if ( currentUser.isPermitted( "winnebago:drive:" + winnebagoId ) ) {"You are permitted to 'drive' the 'winnebago' with license plate (id) 'eagle5'. Here are the keys - have fun!"); } else {"Sorry, you aren't allowed to drive the 'eagle5' winnebago!"); }
    25. 25. Data Contextual Access Control Activity / Feature User User ID Activity ID User Name Data Type Data ID Activity Name Role Data Name Role ID Role Name Entitlement / Privilege User ID Activity ID Role ID Data Type ID Data Instance Id
    26. 26. Please steal and plagiarize this presentation! GET THE WORD OUT