使用 Acegi 中的 Run-As authentication 替換功能可能導致權限擴大漏洞。
Acegi Security 允許在安全對象回調階段臨時替換 SecurityContext 中的 Authentication 對象。只有在 AuthenticationManager 和 AccessDecisionManager 成功處理了 Authentication 對象時才會發生這種情況。RunAsManager 將創建此 Authentication 對象。
開發者通常使用 RunAsManager 在方法調用期間為已認證的用戶配置一個或多個其他角色。對于需要訪問遠程應用程序的安全 bean 而言,這非常有用。由于遠程應用程序可能需要不同憑證,因此,這允許在調用角色的憑證和遠程應用程序所需的憑證之間進行轉換,從而使遠程訪問獲得成功。新的 Authentication 對象(稱為 RunAsUserToken)將僅作為有效的 Authentication 對象被接受,不需要進一步 authentication 或授權檢查。
為新的 Authentication 對象添加新角色或權限可能會暫時擴大用戶的權限,從而使用戶能夠采取未授權的操作。
以下配置顯示使用 RunAsManager 為包含“ROLE_PEON”角色的用戶添加角色“UBER_BOSS”,這樣會使該用戶的權限暫時提高到管理員權限,使所有員工都能夠從 PrivateCatalog 獲得數據。
<bean id="bankManagerSecurity" class="org.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor">
...
<property name="objectDefinitionSource">
<value>
com.example.service.PrivateCatalog.getData=ROLE_PEON,RUN_AS_UBER_BOSS
...
</value>
</property>
</bean>
[1] Standards Mapping - OWASP Top 10 2004 - (OWASP 2004) A3 Broken Authentication and Session Management
[2] Standards Mapping - OWASP Top 10 2010 - (OWASP 2010) A3 Broken Authentication and Session Management
[3] Standards Mapping - OWASP Top 10 2007 - (OWASP 2007) A7 Broken Authentication and Session Management
[4] Ben Alex Acegi Security - Run-As Authentication Replacement
[5] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 724
[6] Standards Mapping - Web Application Security Consortium 24 + 2 - (WASC 24 + 2) Insufficient Authentication
[7] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 - (PCI 1.1) Requirement 6.5.3
[8] Standards Mapping - Payment Card Industry Data Security Standard Version 1.2 - (PCI 1.2) Requirement 6.5.7
[9] Standards Mapping - Payment Card Industry Data Security Standard Version 2.0 - (PCI 2.0) Requirement 6.5.8