Skip to content

Conversation

@GitTimeraider
Copy link
Owner

Potential fix for https://github.com/GitTimeraider/Directadmin-Emailforwarder-docker/security/code-scanning/22

The best way to fix this problem is to ensure that any untrusted text (in this case, selectedDomain) is properly escaped before insertion into an HTML string that is handled by innerHTML. Inserting untrusted data into HTML without escaping leads to XSS vulnerabilities, since special characters are interpreted by the browser as HTML or script content.

General Approach:
Before inserting the error message into tbody.innerHTML, escape any meta-characters in selectedDomain so they are interpreted as text and not as HTML. The simplest safe approach is to create a helper function (escapeHTML) that replaces <, >, &, ", ' in the input string with their corresponding HTML entities.

Specific steps:

  • Create an escapeHTML helper function in static/dashboard.js.
  • When constructing the error message in the catch block of loadForwarders, pass selectedDomain through escapeHTML before concatenation and insertion into innerHTML.

Changes required:

  • Add the escapeHTML function within static/dashboard.js.
  • Change the lines where selectedDomain is inserted into HTML (lines 231 and 233) to use this escaping function.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

dependabot bot and others added 4 commits October 6, 2025 06:46
Bumps [cryptography](https://github.com/pyca/cryptography) from 46.0.1 to 46.0.2.
- [Changelog](https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst)
- [Commits](pyca/cryptography@46.0.1...46.0.2)

---
updated-dependencies:
- dependency-name: cryptography
  dependency-version: 46.0.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
…-46.0.2

Bump cryptography from 46.0.1 to 46.0.2
…as HTML

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…rough an exception

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

2 participants