Repository navigation
2026 06 10 Security Unsanitized API Input
Paulo Gomes da Cruz Junior edited this page Jun 10, 2026
·
1 revision
Category: Security - Input Validation
Effort: Low
Priority: Medium
Component: frontend/src/components/waste/WasteSearch/WasteSearchFiltersAdvanced/AdvancedFilterClientInput/index.tsx
The onAutoCompleteChange handler passes user input (value) directly to the backend API without any validation or sanitization:
onAutoCompleteChange={async (value) =>
(await APIs.forestclient.searchForestClients(value, 0, 10)).map(...)This creates several risks:
- API Abuse: Attackers could send crafted payloads to trigger excessive queries or resource exhaustion
- Injection Attacks: If the backend doesn't properly sanitize, this could lead to SQL injection or NoSQL injection (depending on backend implementation)
- Log Injection: Malicious input could corrupt logs or inject false entries
onAutoCompleteChange={async (value) => {
// Sanitize input: trim whitespace and remove dangerous characters
const sanitizedValue = value?.trim().replace(/[<>"'\]/g, '');
if (!sanitizedValue) return [];
return (await APIs.forestclient.searchForestClients(sanitizedValue, 0, 10)).map(
forestClientAutocompleteResult2CodeDescription,
);
}}onAutoCompleteChange={async (value) => {
const sanitizedValue = value?.trim().replace(/[^a-zA-Z0-9\s\-.,()#]/g, '');
if (!sanitizedValue || sanitizedValue.length < 2) return [];
return (await APIs.forestclient.searchForestClients(sanitizedValue, 0, 10)).map(
forestClientAutocompleteResult2CodeDescription,
);
}}onAutoCompleteChange={async (value) => {
const searchTerm = value?.trim();
if (!searchTerm || searchTerm.length < 2) return [];
return (await APIs.forestclient.searchForestClients(searchTerm, 0, 10)).map(
forestClientAutocompleteResult2CodeDescription,
);
}}frontend/src/components/waste/WasteSearch/WasteSearchFiltersAdvanced/AdvancedFilterClientInput/index.tsx- Backend API:
forestclient.searchForestClientsendpoint (should also validate)
- Verify that special characters in search input don't break the UI or cause errors
- Confirm that very short queries (< 2 chars) don't trigger unnecessary API calls
- Test that the backend handles sanitized input correctly
This wiki documents NR Waste Plus for users and developers. Verify security and deployment guidance against the current application configuration before applying it elsewhere.
- Report an issue or ask a question in the GitHub repository.
- Follow the Contributing Guidelines to propose an update.
- Read the Code of Conduct.
Collection indexes support human browsing and machine retrieval. Keep both current when adding or moving wiki pages.
NR Waste Plus Wiki | GitHub Repository