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

Ensure URLs in dispute order note are urlencoded before passed to add_query_arg() to follow best practice #7399

Closed
Jinksi opened this issue Oct 6, 2023 · 8 comments · Fixed by #9788
Assignees
Labels
component: disputes Issues related to Disputes focus: disputes good first issue The issue is a good candidate for the first community contribution/for a newcomer to the team. priority: medium The issue/PR is medium priority—non-critical functionality loss, minimal effect on usability type: bug The issue is a confirmed bug.

Comments

@Jinksi
Copy link
Member

Jinksi commented Oct 6, 2023

URLs query string parameters used for links to the transaction details screen from disputed order notes are not URL-encoded.

add_query_arg() does not encode the parameter value. It expects the parameter value already encoded which currently, it is not url-encoded.

// current
-/wp-admin/admin.php?page=wc-admin&path=/payments/transactions/details&id=ch_123

// preferred
+/wp-admin/admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_123

Note

Nothing breaks due to this issue. It's just that it's not a best practice that was picked up from #7087 (comment).

When @Jinksi tried to url-encode it, a new problem arose #7087 (comment). Hence, it needs further investigation as to why that is.

@Jinksi Jinksi added type: bug The issue is a confirmed bug. component: disputes Issues related to Disputes labels Oct 6, 2023
@Jinksi Jinksi added the good first issue The issue is a good candidate for the first community contribution/for a newcomer to the team. label Oct 6, 2023
@haszari
Copy link
Contributor

haszari commented Oct 11, 2023

non-browser-compliant URLs.

Is this an issue? As I understand it this string should be escaped correctly. The chance of it being exploited is probably low, so this might be a linter / best practice issue.

@Jinksi
Copy link
Member Author

Jinksi commented Oct 11, 2023

non-browser-compliant URLs.

Thanks @haszari, I am incorrect in that statement so I've removed it. I had in my mind that all reserved characters need to be percent-encoded when being used in a query string.

But / and ? are allowed within the query string – all other reserved characters should be percent-encoded.

From https://www.rfc-editor.org/rfc/rfc3986#section-3.4:

The characters slash ("/") and question mark ("?") may represent data within the query component.

...as query components are often used to carry identifying information in the form of "key=value" pairs and one frequently used value is a reference to another URI, it is sometimes better for usability to avoid percent-encoding those characters.

@haszari
Copy link
Contributor

haszari commented Dec 19, 2023

@Jinksi can you test or investigate to confirm if there's impact/risk here? Not clear from the description, I figure someone needs to explore.

  • If this is breaking something or is a security risk, let's prioritise.
  • If this is not affecting anything and no risk we can close.

@haszari haszari added pr: needs author reply needs feedback The issue/PR needs a response from any of the parties involved in the issue. needs prioritisation Triage finished and issues are ready for the following processing. and removed pr: needs author reply labels Dec 19, 2023
@Jinksi
Copy link
Member Author

Jinksi commented Dec 20, 2023

IMO there is no real impact or risk here.

@shendy-a8c can I get your opinion on this? Uou noticed this as a problem in code review #7087 (comment) and may have a better idea of the impact this could have.

@shendy-a8c
Copy link
Contributor

shendy-a8c commented Dec 20, 2023

I can't see any risk or impact. It's just that it's not a best practice.
As I stated in #7087 (comment), add_query_arg() does not encode the parameter value. It expects the parameter value is already encoded which currently, the string in the code is not url-encoded.

@haszari
Copy link
Contributor

haszari commented Dec 20, 2023

Thanks @shendy-a8c – based on that this is a mini tech debt issue and we should fix it when we get a chance. Setting as low priority 👍🏻

@haszari haszari added the priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. label Dec 20, 2023
@haszari
Copy link
Contributor

haszari commented Dec 20, 2023

@shendy-a8c can you update the description and title so it's super clear what the problem is, and what the outcome/goal is? So it's easy for anyone to pick up and action 🚀

@shendy-a8c shendy-a8c changed the title Ensure URLs in dispute order note are urlencoded Ensure URLs in dispute order note are urlencoded before passed to add_query_arg() to follow best practice Dec 22, 2023
@haszari haszari added priority: medium The issue/PR is medium priority—non-critical functionality loss, minimal effect on usability and removed priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. needs prioritisation Triage finished and issues are ready for the following processing. labels Feb 15, 2024
@haszari
Copy link
Contributor

haszari commented Feb 15, 2024

Upgrading to medium priority as this is a code best practice that we should do. If this is impractical or not needed we can close.

@souravdebnath1986 souravdebnath1986 removed the needs feedback The issue/PR needs a response from any of the parties involved in the issue. label Feb 15, 2024
@brucealdridge brucealdridge self-assigned this Nov 19, 2024
@brucealdridge brucealdridge added this to the WooPayments 8.6.0 milestone Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: disputes Issues related to Disputes focus: disputes good first issue The issue is a good candidate for the first community contribution/for a newcomer to the team. priority: medium The issue/PR is medium priority—non-critical functionality loss, minimal effect on usability type: bug The issue is a confirmed bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants