-
Notifications
You must be signed in to change notification settings - Fork 31
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
WordPress and Recursive unserialize #114
Comments
additional information: https://medium.com/websec/wordpress-and-the-notorious-unserialize-4b1ecce797a |
I checked function test_recursive_unserialize_replace(ReplaceTest.php) for a, O, C, o, s, S, +, ; (as it described in medium link). Then I added to serializedDataProvider() some data for checking and it works, if I understand correctly.
|
Hi @bueltge, Sure, I will try. |
Commit related to wp-media#114. More test data for testing recursive_unserialize_replace()
I checked |
Hi @bvdv, Thanks for the help. The |
Hi @widoz, |
Hi @bvdv, Thanks for the explanation. I wasn't sure we had to unserialize it or not. I have a doubt now that concern the replace to Probably I'm still missing something. |
Hi @widoz, Sorry again, my bad, result for |
What I meant was, shouldn't Because sounds like this step serialize the string and I think doesn't make sense because the original one is a valid serialized string.
Even my example above is wrong, technically we should skip strings like that and produce a log for the user that an invalid serialized string was found. |
I thought that it is as some possibility for user( or third party function) to serialize or not something even it is invalid value, if the user really wants it. Because of that, I never thought why it being serialized? |
Yes, sorry that is the right code that serialize the string not the one I have posted. Also, something here https://medium.com/websec/wordpress-and-recursive-unserialize-5518b124b23b look different than our implementation. For example: We are missing the conditional that check if the string is a serialized string and it's serialized. The latest else block replace the normal string so The problem that this get serialized seems it is because the default value for the serialized parameter is set to true instead of false. Means probably we have to revisit where and how this functions is called. I'm wrong or missing something? |
@widoz,
It depends, according to that commit there was a need to receive serialized data or it was idea to set to false internally. It's hard for me to say right away, what that idea was.
So far I have considered this function just how it implements suggested rules from both Medium post.
I don't know, all comments are fair. Currently I think that I missing something. :)
Look like implementation from https://medium.com/websec/wordpress-and-recursive-unserialize-5518b124b23b has more checks at once at input. |
@bvdv I had a look at the code again, could you kindly check the changes I made here https://github.com/inpsyde/search-and-replace/tree/issue/114 ? I haven't tested a different solution that could be something like:
Anyway, to me sounds like we have just replace the invalid serialized value as a normal string or do nothing. Assuming that since it's a valid serialized data, who wrote that in the db know what he's doing and in case we convert it to a serialized string or we simply replace the value we are compromising the data. We cannot assume 100% every invalid WP serialized string is a problem. What do you think? Sorry I don't remember the commit, was a lot of time ago :/ I need some more time to remember why that decision was made. |
Hi @widoz, sorry for my late reply.
Sorry, I not quite understand, why new changed function return unserialized data for valid serialized input? May be for that reason
Seems yes, if it don't assume use recursively
I too think that function should just replace the invalid serialized value as a normal string or return some alert that value is invalid but as you think not ever invalid string is a problem, Could you please little bit explain what to do this code.
|
Context
After the post in medium about the WordPress and serialize bug that can be read here https://medium.com/websec/wordpress-and-recursive-unserialize-5518b124b23b the fix has been applied to search-and-replace.
What we have now
Now I've refactoring some code and create test for the method
recursive_unserialize_replace
.To us this is a crucial part, be sure the bug isn't reintroduced and will never be by add more tests for that logic.
I created a data provide to allow us to pass a data and an expected replaced viewable here https://github.com/inpsyde/search-and-replace/blob/master/tests/UnitTests/Database/ReplaceTest.php#L348
What is needed
It's needed more example of possible serialized data/expected in order to introduce them into the test.
Regarding the bug as described in the article, the
$s = "s:+3:\"grr\";";
let outs:3:\”grr\”;
.I'm not pretty sure but the issue is with the missed
+
or it's about the missed;
at the end of the string?The text was updated successfully, but these errors were encountered: