-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
The parameters in path may be overwritten by the parameters with the same name in query #1757
Comments
This is same as #1670 and addressed in multiple ways in different PRs (already in master branch - waiting to be released)
In current version what you can do - do not mix json binding with param/query binding. For body/json if err := json.NewDecoder(c.Request().Body).Decode(&payload); err != nil {
return err
} For path petID, err := strconv.ParseInt(c.Param("pet_id"), 10, 64)
if err != nil {
return err
} For query petID, err := strconv.ParseInt(c.QueryParam("pet_id"), 10, 64)
if err != nil {
return err
} it is longer but avoids mixing up where data is taken in next release it will be much easier to handle this stuff |
This is due to This has been addressed in #1681 where explicit binding is done instead and although hasn't been officially released can be accessed with this version suffix v4.1.18-0.20210107234338-9b0e63046b13 I'd advise to not change to this unreleased version if it's a production app except you really know what you're doing. I currently use it and it tackles the issue for me. |
Thanks for your reply, I understand, thanks again. |
Thanks for your reply, I will close this issue now. |
Issue Description
Hi guys, I encountered such a problem while using echo. The parameters in path may be overwritten by the parameters with the same name in query.
Checklist
Expected behaviour
Actual behaviour
Steps to reproduce
For example, the following example:
First request:
output is
{PetID:1 Name:Bear}
, and this is as expected.If now an attacker passes the
path
parameter with the same namequery
parameterpet_id
:The output at this time is not what I expected,
pet_id
is overwritten:Is the above situation a known normal situation?
Working code to debug
Version/commit
go version go1.14.11 darwin/amd64
github.com/go-playground/validator/v10 v10.4.1
github.com/labstack/echo/v4 v4.1.17
The text was updated successfully, but these errors were encountered: