Skip to content

Latest commit

 

History

History
66 lines (47 loc) · 5.91 KB

File metadata and controls

66 lines (47 loc) · 5.91 KB

Mitigation Strategies Analysis for impress/impress.js

Description:

  1. No Sensitive Data in data-*: Ensure that no sensitive information (API keys, user details, internal notes, etc.) is ever placed directly within the impress.js data-* attributes used for positioning, rotation, scaling, or any other presentation parameters. These attributes are part of the HTML and are easily visible in the browser's developer tools.
  2. JavaScript-Driven Data Loading: Use JavaScript to fetch any dynamic data after the impress.js presentation has initialized. This should be done using secure AJAX requests (HTTPS) and the data should be stored in appropriately scoped JavaScript variables, not directly inserted into the data-* attributes.
  3. Avoid innerHTML with Untrusted data-* Values: Even if the data-* attributes themselves don't contain sensitive data, if their values are derived from user input, be extremely cautious. Prefer using DOM manipulation methods that don't involve parsing HTML strings. If you must use innerHTML, ensure the values are thoroughly sanitized before being used to construct the HTML.

Threats Mitigated:

  • Data Leakage through Step Attributes (Severity: High): Directly prevents the primary threat of exposing sensitive data embedded in impress.js's configuration attributes.
  • Information Disclosure (Severity: High): Reduces the risk of accidentally exposing sensitive data through the presentation structure.

Impact:

  • Data Leakage: Risk is virtually eliminated if implemented correctly.
  • Information Disclosure: Significantly reduced, as sensitive data is never directly part of the easily inspectable HTML.

Currently Implemented: (Example - Replace with your project's specifics)

  • All presentation data is loaded via AJAX after impress:init in src/js/data-loader.js.
  • data-* attributes only contain presentation-related values (position, rotation, etc.).

Missing Implementation: (Example - Replace with your project's specifics)

  • Need to audit all uses of data-* attributes to double-check that no dynamically generated content (even if not directly sensitive) is being inserted without proper sanitization.

Description:

  1. Whitelist of Step IDs: Maintain a JavaScript array or object containing a list of all valid step IDs in your impress.js presentation. This whitelist represents the allowed navigation targets.
  2. Input Validation: Whenever impress().goto() is called, before executing the navigation, check if the target step ID (which might come from a URL parameter, user input, or another source) exists in the whitelist.
  3. Rejection/Redirection: If the provided step ID is not found in the whitelist, either:
    • Reject the navigation request entirely (do nothing).
    • Redirect the presentation to a safe, default step (e.g., the first step).
  4. Never Trust User Input: Never directly use user-provided input as the argument to impress().goto() without this validation.

Threats Mitigated:

  • JavaScript Injection via goto() (Severity: High): Prevents attackers from crafting malicious URLs or inputs that would cause impress().goto() to execute arbitrary JavaScript code (e.g., using a javascript: URI).

Impact:

  • JavaScript Injection: Eliminates the risk of this specific type of injection if the whitelist is correctly maintained and the validation is consistently applied.

Currently Implemented: (Example)

  • No goto() calls currently use direct user input. All navigation is handled internally.

Missing Implementation: (Example)

  • Implement a whitelist check in src/js/navigation.js for the URL hash-based navigation, even though it currently only uses internal step IDs. This adds a layer of defense in depth.

Description:

  1. Identify Event Handlers: Identify all custom event handlers that you've attached to impress.js events (e.g., impress:stepenter, impress:stepleave, impress:init).
  2. Data Source Analysis: For each event handler, carefully analyze where the data it processes comes from. Is any of this data derived from user input, URL parameters, or external sources?
  3. Sanitization and Validation: If any data processed by the event handler originates from an untrusted source, apply rigorous sanitization and validation before using that data. This is the same process as for preventing XSS in general, but applied specifically within the context of impress.js event handlers.
  4. Avoid eval() and related: Never use eval(), Function(), setTimeout or setInterval with string containing unsanitized user input that comes from event.

Threats Mitigated:

  • Cross-Site Scripting (XSS) via Event Handlers (Severity: High): Prevents attackers from injecting malicious code that would be executed when specific impress.js events are triggered.

Impact:

  • XSS: Significantly reduces the risk of XSS vulnerabilities arising from custom event handler logic.

Currently Implemented: (Example)

  • The impress:stepenter handler in src/js/custom-events.js only uses data from the event.target (the step element itself) and does not process any external data.

Missing Implementation: (Example)

  • Add a new event handler for impress:message (a hypothetical custom event) that receives data from a WebSocket connection. This handler must sanitize the incoming message data before displaying it.