Summary
A reflected cross-site scripting (XSS) flaw in the WeGIA web manager allows attacker-controlled data from the id_memorando GET parameter to be rendered back into the HTML response without proper escaping.
When a victim visits a crafted URL, this flaw can be used to execute arbitrary JavaScript in their browser, potentially leading to session hijacking, data theft, or unauthorized actions in the WeGIA application.
Affected context
The vulnerability occurs in the WeGIA web application prior to version 3.6.2, specifically in html/memorando/insere_despacho.php.
It affects any deployment where:
- User-supplied data from the
id_memorandoGET parameter is reflected into the HTML response, and - The output is inserted into a
<script>block, HTML attribute, or other JavaScript-capable context without robust encoding.
The risk materializes when users follow attacker-crafted links or are redirected via phishing emails, embedded links in other systems, or malicious third-party websites.
Exploit preconditions
- Attack surface: Public or internal web interface of WeGIA, reachable over HTTP(S).
- Required access: None; the attacker can be fully unauthenticated as long as they can cause a victim to load a crafted URL.
- Trigger point: The vulnerable
insere_despacho.phpendpoint processes theid_memorandoGET parameter and embeds it into the server-generated HTML response. - Why exploitation is possible: The application trusts the raw query parameter value and injects it into a script or attribute context without context-appropriate output encoding or sanitization, allowing attacker-supplied JavaScript to be interpreted by the browser.
Why this happens
This issue is an instance of CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting).
The id_memorando parameter is treated as displayable content and is directly inserted into HTML/JavaScript output without applying:
- context-aware encoding (e.g., HTML-encoding, JavaScript string escaping), or
- stricter validation to restrict its character set and structure.
As a result, crafted values can break out of the intended context (such as a string or attribute) and inject new HTML or script elements.
The underlying pattern is mixing untrusted input with server-side templates without a robust, default-safe output encoding strategy.
Potential impact
- Execution of arbitrary JavaScript in the victim's browser within the WeGIA origin.
- Theft of session cookies or other authentication tokens if they are accessible to client-side scripts.
- Impersonation of users by performing actions on their behalf (e.g., viewing or modifying records) while they are authenticated.
- Injection of fake UI elements or phishing forms to trick users into revealing sensitive information.
- Defacement of application pages or injection of malicious content that persists in browser history or logs.
General mitigation guidance
Effective mitigation focuses on context-aware output encoding and strict handling of untrusted input:
- Use templating or view frameworks that apply automatic, context-appropriate output encoding by default for all untrusted data.
- Apply HTML encoding to values inserted into HTML body content, attribute encoding for attribute contexts, and JavaScript string escaping when injecting into script blocks.
- Treat query parameters such as
id_memorandoas untrusted and validate them against strict allow-lists (e.g., numeric IDs or constrained patterns) before usage. - Separate data from code in templates; avoid building raw JavaScript or HTML using string concatenation with user input.
- Enforce least privilege in client-side code: avoid exposing sensitive data to JavaScript unless strictly necessary.
- Consider using security headers like Content Security Policy (CSP) to reduce the impact of potential XSS, while not relying on them as the sole defense.
How teams detect issues like this
Identifying this kind of XSS vulnerability typically involves a mix of automated and manual techniques:
- Static analysis: Configure rules to flag direct insertion of request parameters (e.g.,
$_GET['id_memorando']) into HTML or script output functions without encoding. - Template review: During code review, examine templates and PHP views for string concatenation of user-controlled data inside
<script>tags, event handlers (onclick,onload), orhref/srcattributes. - Dynamic testing: Use web vulnerability scanners or interactive testing to send payloads in the
id_memorandoparameter and observe whether they appear unencoded in the rendered page. - Policy enforcement: Adopt internal guidelines that require context-aware escaping utilities, and monitor pull requests for direct echo/print of superglobals (
$_GET,$_POST) into views. - Automated code review tools can be configured to look for common XSS anti-patterns and alert reviewers early in the development process.

