Skip to content

[Chore] [Security & CI] Prevent privilege escalation and optimize Jest PR workflow #6023

@varruunnn

Description

@varruunnn

Description:
The current pr-jest-tests.yml workflow has a critical security vulnerability and several performance inefficiencies.

Vulnerabilities & Issues:

Privilege Escalation Risk: Using the pull_request_target trigger alongside an explicit PR code checkout allows untrusted code to run in a privileged context during dependency installation. A malicious PR could potentially execute arbitrary code (e.g., via npm install lifecycle scripts).

Inefficient Installs: Using npm install without caching slows down the pipeline and introduces non-deterministic dependency trees.

Proposed Solution:

Secure the workflow by switching to the standard pull_request trigger to isolate untrusted code.

Remove the explicit ref checkout override.

Switch to npm ci --ignore-scripts for faster, deterministic, and highly secure dependency installation.

Optimize performance by adding cache: 'npm' to the setup-node action.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions