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

API Escaping Single Quote When Assigned_User Key is Used in Request Body #11805

Open
2 tasks done
sean-sauve opened this issue Sep 10, 2022 · 4 comments
Open
2 tasks done

Comments

@sean-sauve
Copy link

sean-sauve commented Sep 10, 2022

Debug mode

Describe the bug

When making a POST request via the API on the hardware endpoint, and a single quote (') is in the name of the asset, this single quote sometimes (but not always) appears as &# 039; in the created asset name. This escaped character does not happen if the request body contains only the keys asset-tag, status_id, model_id, and name. It does happen though if the assigned_user key is in the request body.

Reproduction steps

  1. Send a POST request to api/v1/hardware with the name key containing ' in the value of the name, and without the assigned_user key. The asset name will be added to the database with the ' character not escaped.
  2. Send a POST request to api/v1/hardware with the name key containing ' in the value of the name, and WITH the assigned_user key. The asset name will be added to the database with the ' character escaped as &# 039;

Expected behavior

Data should be entered into the database as it is submitted to the API.

Screenshots

image

image

Snipe-IT Version

v6.0.9 - build 8515

Operating System

ubuntu

Web Server

Apache

PHP Version

PHP 8.1.2

Operating System

N/A: Postman and PowerShell Invoke-WebRequest

Browser

N/A: Postman and PowerShell Invoke-WebRequest

Version

N/A: Postman and PowerShell Invoke-WebRequest

Device

N/A: Postman and PowerShell Invoke-WebRequest

Operating System

N/A: Postman and PowerShell Invoke-WebRequest

Browser

N/A: Postman and PowerShell Invoke-WebRequest

Version

N/A: Postman and PowerShell Invoke-WebRequest

Error messages

No response

Additional context

No response

@welcome
Copy link

welcome bot commented Sep 10, 2022

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

@snipe
Copy link
Owner

snipe commented Sep 11, 2022

The data in the database is likely not escaped - we escape on the way out, to prevent XSS attacks.

@sean-sauve
Copy link
Author

I did notice that there is escaped data on the way out during some other calls and have worked around that. Unfortunately, that's not it in this case. In this case the data really is modified in the database; please see below

image

@sean-sauve
Copy link
Author

This is still an issue.

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

No branches or pull requests

2 participants