Summary
WeGIA versions 3.6.6 and below contain a reflected Cross-Site Scripting (XSS) vulnerability in the listar_memorandos_ativos.php endpoint, where untrusted data from the sccd query parameter is echoed directly into an HTML alert message.
An attacker can craft a malicious link that injects arbitrary JavaScript or HTML, which executes in the victim's browser when they visit the URL, potentially leading to session theft, account impersonation, or other client-side attacks.
Affected context
The vulnerability occurs in WeGIA's Memorando module within the listar_memorandos_ativos.php script, specifically when handling dynamic success messages passed via query string parameters.
When the msg parameter equals success, the application concatenates the sccd GET parameter directly into an HTML <div> alert without output encoding or sanitization.
This behavior is present in WeGIA versions 3.6.6 and below and manifests when user-controlled data is reflected in server-generated HTML responses.
Exploit preconditions
- Attack surface: HTTP GET request to /html/memorando/listar_memorandos_ativos.php
- Required access: The ability to convince a user to visit a crafted URL (e.g., via email, chat, or embedded links); no authenticated session is strictly required for the browser to process the malicious script, though impact increases with authenticated users.
- Trigger point: Server-side rendering of an HTML page when:
- The msg GET parameter equals "success"
- The sccd GET parameter contains attacker-controlled JavaScript or HTML
- Why exploitation is possible: The application directly reflects the sccd parameter into an HTML alert <div> without applying context-appropriate output encoding or validation, allowing injected script to be interpreted and executed by the browser.
Why this happens
This issue is rooted in improper neutralization of user-controlled input before it is included in the HTML response, mapping to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting).
The listar_memorandos_ativos.php script assumes that the sccd query parameter is safe and concatenates it into an HTML structure when msg == "success".
Because no HTML or JavaScript output encoding is applied, the browser interprets any embedded script or markup as part of the page, enabling arbitrary client-side execution.
Conceptually, this reflects a broader bug class where server-generated views treat query parameters as trusted display content rather than untrusted input requiring encoding.
Potential impact
- Theft of session identifiers or authentication tokens from affected users' browsers
- Execution of arbitrary JavaScript in the context of the WeGIA application
- Forced actions on behalf of authenticated users (e.g., changing data, sending internal memorandos), if combined with application functionality
- Defacement or manipulation of visible content within the Memorando interface
- Pivoting to more advanced browser-based attacks such as keylogging or credential harvesting
General mitigation guidance
Mitigation focuses on robust output encoding and strict handling of untrusted input in server-rendered views:
- Apply context-appropriate output encoding to all dynamic values rendered into HTML (e.g., HTML entity encoding for text nodes, attribute encoding within attributes, and JavaScript string encoding where applicable).
- Treat all query parameters (including sccd and msg) as untrusted user input and validate them against a strict allowlist of expected characters and formats.
- Prefer structured server-side status handling (e.g., enumerated codes or IDs) instead of directly reflecting arbitrary messages supplied via the query string.
- Centralize output encoding logic in reusable view helpers or templating functions so that all dynamic content is encoded by default.
- Implement a security-conscious template engine configuration that discourages raw output and defaults to safe-escaped variables.
How teams detect issues like this
Detection can combine automated and manual review techniques:
- Static analysis: Configure rules that flag direct use of $_GET, $_POST, or $_REQUEST values concatenated into HTML strings or echoed without passing through an encoding or sanitization layer.
- Code review: Examine view scripts such as listar_memorandos_ativos.php and other Memorando module endpoints for patterns like
echo $_GET[...]or string interpolation mixing HTML and raw query parameters. - Security testing: Use automated scanners or manual penetration testing to crawl URLs with reflected parameters, injecting harmless test payloads to identify unencoded reflections.
- Policy enforcement: Introduce coding standards that require all user-derived data to be passed through standardized encoding helpers in the presentation layer and enforce these via pre-commit hooks or CI checks.

