spring-projects / spring-projects/spring-security
SEC-2189: <sec:authorize url=""> could use wrong WebInvocationPrivilegeEvaluator
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
q (Migrated from SEC-2189) said:
When using <sec:authorize url=""> it is possible situation when wrong WebInvocationPrivilegeEvaluator is used for access evaluation
It occurs when in security xml descriptor there're different contexts
and in the jsp in second context we use <sec:authorize url=""> to access url from second context.
for example:
in security.xml:
<http pattern="/qwe/" ...>
...
</http>
<http pattern="/admin/" ...>
<intercept-url pattern="/admin/stats/**" access="hasRole('ROLE_ADMIN')"/>
...
</http>
in /admin/index.jsp:
<sec:authorize url="/admin/stats/index.jsp">
<a href="<spring:url value="/admin/stats/index.jsp"/>">link</a>
</sec:authorize>
on the /admin/index.jsp link will be displayed even if user doesn't have ROLE_ADMIN
It appears that the problem is in
org.springframework.security.taglibs.authz.AbstractAuthorizeTag#getPrivilegeEvaluator:
Map<String, WebInvocationPrivilegeEvaluator> wipes = ctx.getBeansOfType(WebInvocationPrivilegeEvaluator.class);
....
return (WebInvocationPrivilegeEvaluator) wipes.values().toArray()[0];
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in org.springframework.security.taglibs.authz.AbstractAuthorizeTag#getPrivilegeEvaluator and inspect how multiple WebInvocationPrivilegeEvaluator beans are selected. Reproduce the example with separate contexts and an authorization tag targeting the second context. Done means the tag evaluates the URL with the evaluator for that context and does not display the link without ROLE_ADMIN.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- authorization, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100