Security Enhancements #97
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🛡️ Input Sanitization & Security Hardening
Purpose of the Change
This change introduces input sanitization mechanisms to the handling of user-influenced strings like
backupName
andquery
. These values are passed into APIs, UI keys, local storage, and internal logic. To ensure application resilience and reduce potential abuse vectors, we sanitize them to:⚙️ What has changed
1.
_sanitizePlaceName()
added to_HomePageState
Used to clean the
backupName
field before it's used in API calls, logic branches, and UI widgets.2.
LocationService
is created following best practices to to improve code readability and maintenance3.
_sanitizeQuery()
added toLocationService
Used to clean the
query
parameter before being passed toweatherapi
orOM
APIs.These functions ensure only:
a-zA-Z0-9_
)are accepted. Also, no more than 100 characters are processed to void Buffer overflows from extremely long inputs.
4. Using
Uri.Https()
instead ofUir.Http()
that aligns with OWASP guidelines. Sensitive Data Exposure (OWASP Mobile Top 10: M1) and Insecure Communication (OWASP Mobile Top 10: M3).📊 Impact of the Change
High-risk areas existed because:
However, there was no critical vulnerabilities like RCE or injection, because:
Uri.https
)That said, failure to sanitize is still a high-risk code smell and leaves open potential for:
📚 OWASP Mobile Top 10 Compliance
These changes align with best practices and mitigate risks outlined in the OWASP Mobile Top 10.