Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix double evaluations #496

Merged
merged 7 commits into from
Mar 15, 2022
Merged

Conversation

yasserzamani
Copy link
Member

@coveralls
Copy link

coveralls commented Jul 9, 2021

Coverage Status

Coverage increased (+0.2%) to 47.553% when pulling e7834d4 on fix/double_evaluations_2_5 into 8d0382c on struts-2-5-x.

@lukaszlenart
Copy link
Member

lukaszlenart commented Jul 24, 2021

I have a huge concern if such a big change should be introduced in a minor version like 2.5.27 - I'm ok with having it in 2.6 as this is natural to break backward comaptibility in a major version release. Users can be heavily impacted by these changes and won't be able update their apps.

@yasserzamani
Copy link
Member Author

Thanks @lukaszlenart I see. For me that has spent plenty of time on it, I remember it was obviously safe changes, but please let me double check, I'll let you know.

P.S. actually I like these changes for 2.5 because they improve Struts to behave better in currently publicly known double evaluation reports. It also contains small yet safe other improvements. Please consider it as an ordinary PR that somebody like to improve Struts. And please let me know any possibility of backward-compatibility issue.

@yasserzamani
Copy link
Member Author

@lukaszlenart I double checked and couldn't find any. Maybe to make it simpler just skip tests files review. Then you'll see obvious safe and nice changes. Test coverage is also increased 0.2%!

@lukaszlenart
Copy link
Member

Tests are the most important in this change as changing existing tests means you probably introduced breaking changes as users can depend on the buggy implementation.

@yasserzamani
Copy link
Member Author

@lukaszlenart I double checked and host of them are additions or just java language improvements. Existing tests' functional changes are:

-assertEquals(bean.escape("hello!world"), "hello!world");
-assertEquals(bean.escape("hello!@#$%^&*()world"), "hello!@#$%^&*()world");
+assertEquals(bean.escape("hello!world"), "hello_world");
+assertEquals(bean.escape("hello!@#$%^&*()world"), "hello__________world");

which isn't a breaking changes because it's an Struts' internal change.

-tag.setId("cb.bc");
+tag.setId("cb['\".\"'] = bc(){};//");

and consequently

-<td class="tdLabel"><label for="cb.bc" class="label">mylabel:</label></td>
+<td class="tdLabel"><label for="cb['&quot;.&quot;']=bc(){};//" class="label">mylabel:</label></td>
...
-function autoPopulate_cb_bc(targetElement) {
+function autoPopulate_cb__________bc_______(targetElement) {
-<input type="text" name="foo" value="hello" id="cb.bc"/><br/>
-<select onChange="autoPopulate_cb_bc(this);">
+<input type="text" name="foo" value="hello" id="cb['&quot;.&quot;']=bc(){};//"/><br/>
+<select onChange="autoPopulate_cb__________bc_______(this);">

which isn't a breaking changes because it's an Struts' internal change.

-        <input type="radio" name="myMap['name']" id="myMap_'name'_"value=""/>
-        <label for="myMap_'name'_">N/A</label>
-        <input type="radio" name="myMap['name']" id="myMap_'name'_Opt." value="Opt."/>
-        <label for="myMap_'name'_Opt.">Opt.</label>
-        <input type="radio" name="myMap['name']" id="myMap_'name'_Std." checked="checked" value="Std."/>
-        <label for="myMap_'name'_Std.">Std.</label>
+       <input type="radio" name="myMap['name']" id="myMap__name__"value=""/>
+       <label for="myMap__name__">N/A</label>
+       <input type="radio" name="myMap['name']" id="myMap__name__Opt." value="Opt."/>
+       <label for="myMap__name__Opt.">Opt.</label>
+       <input type="radio" name="myMap['name']" id="myMap__name__Std." checked="checked" value="Std."/>
+       <label for="myMap__name__Std.">Std.</label>

which isn't a breaking changes because it's an Struts' internal change.

BTW can I merge at my own risk and responsibility? @apache/struts-committers

@lukaszlenart
Copy link
Member

@yasserzamani me and @aleksandr-m expressed our concerns with introducing this change into the 2.5.x branch and you still ignore our votes and pushing your opinion. This not the the Apache way of collaborating.

I have a suggestion, we can release the current state of the 2.5.x branch as Struts 2.5.27 and then introduce your change and release 2.5.28 which will contain only your change. I think this is the safest option we have.

@yasserzamani
Copy link
Member Author

I think its philosophy is respectful, honest, technical-based interaction not concern-based and technically we haven't any reason I think.

But at bottom as per respectful OK 👍 I keep this PR open for the second next release :) thanks a lot for your contribution and comments!

@lukaszlenart
Copy link
Member

My technical reason is very simply: this PR will be mixed in with other changes and if users start complain that something doesn't work after upgrade it can be very hard for us to figure out what's the core issue - this change or the other changes. If you want to you can prepare a strict security fix based on a STRUTS_2_5_26 tag and then release it separately. From my experience mixing security fixes with bug fixes isn't a good idea.

@aleksandr-m
Copy link
Contributor

@yasserzamani Why dynamicAttributes type is changed?

@yasserzamani
Copy link
Member Author

@aleksandr-m thanks for asking! Now by merging upstream into this branch by me, a test of TextField has two dynamic parameters set (one added by Lukasz). Then I saw that tests are passing with jdk7 and are failing with jdk8 and newer. Then I realized that different JDKs return different order for HashMap.entrySet(). So I changed to LinkedHashMap which keeps order to avoid a workaround like click here. Furthermore I think it's nice to keep dynamic attributes order same as added by user. And at bottom, LinkedHashMap is also a Map so I think it shouldn't be a breaking change.

@yasserzamani
Copy link
Member Author

@aleksandr-m LinkedHashMap didn't help either. I just reverted it and instead I fixed (improved) the corresponding test to be able to verify against any of multiple possibilities.

@lukaszlenart
Copy link
Member

LGTM 👍

@lukaszlenart lukaszlenart merged commit e1209fd into struts-2-5-x Mar 15, 2022
@lukaszlenart lukaszlenart deleted the fix/double_evaluations_2_5 branch March 15, 2022 13:33
fp024 added a commit to fp024/struts2-study that referenced this pull request Apr 11, 2022
  https://struts.apache.org/announce-2022#a20220404
  apache/struts#496
  https://securitylab.github.com/research/apache-struts-double-evaluation/https://github.com/m-y-mo/alias-example
       ㄴ 악의적 동작을 실행하는 ONGL 표현식 문자열을 Alias 인터셉터가 설정된 액션에
              전달해야할 듯 한데,...  예제 프로젝트를 만들어보긴했지만.....😥😥😥
              재현은 못했다...
              이중 평가가 되지 않도록 구현하는 것이 안전하다는 것은 약간이나마 알 것 같다.

- 기타 수정
  - web.xml 스키마 4.0으로 변경
  - 몇몇 프로젝트의 struts.xml 에서 package 하위 요소 순서가 잘못된 부분 수정
  - Jetty 서버 사용시 콘솔에서 Enter눌러 리로딩 되도록 변경
    Jetty 전버전에선 리로딩시 StrutsPrepareAndExecuteFilter 로딩이 제대로 안되었는데, 현시점 현재 환경에서는 잘된다.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants