• The new Python extension is now available. It allows customers to deploy and manage WSGI-based Python applications on their websites directly from Plesk.
  • The Plesk Mobile apps for iOS and Android and the Plesk Mobile Center extension have been deprecated, and are no longer available for new installations. In Plesk Obsidian 18.0.84, the Plesk Mobile Center extension will be removed from servers during the upgrade, and the Plesk Mobile apps will lose their server management features.
  • The Social Login extension has been deprecated and will be removed in Plesk Obsidian 18.0.84. After that, it will no longer be possible to log in to Plesk with a Google, Facebook, GitHub account, or with a passkey. Plesk usernames and passwords, as well as logging in with a WebPros Account, are not affected.

Issue Plesk NodeJS file direct access - vulnerability

michal2013

New Pleskian
How can I prevent direct access to `app.js`

When anyone accesses 'example.com/app.js' I m able to see all the code inside the app.js that is not safe and secure

Plesk has to understand the situation and find/provide the proper solution for this.

My project structure is given below
HOST: 'www.example.com'
`
D:\PROJECT - LIVE\IMS\
├── app.js # Main application entry point
├── ecosystem.config.js # PM2 configuration
├── package.json
├── package-lock.json
│
├── certificate/ # SSL certificates
├── keys/ # Security keys
│
├── config/
│ └── myDB.js
│
├── cronjobs/
│ └── cronjob.js
│
├── middleware/
│ ├── mPermission.js
│
├── routes/
│ ├── index.js
│ ├── router.js
│ ├── ADMIN/
│ │ ├── mail.js
│ │ └── CREDENTIAL/
│ │ └── credential.js
│ ├── CHAT/
│ │ └── chatRoutes.js
│ ├── login/
│ │ └── loginPage.js
│ ├── PROFILE/userProfile/
│
├── public/
│ ├── images/
│ │ └── favicon.png
│ └── stylesheets/
│ └── style.css
│
├── views/
│ ├── error.html
│ ├── error.jade
│
├── uploads/
│ ├── file/
├── tmp/
└── node_modules/
`
 
Hi,

PM2 on Plesk? I don't think that's going to work.

But regarding your issue, can you post a screenshot of the Node.js settings? Did you assign app.js to "Application Startup File"?
 
We can ignore ├── ecosystem.config.js # PM2 configuration
"Application Startup File" is `app.js`

this nodejs runs on Plesk Panel

issue I can able to direct access the js code inside the app.js when I try to access like `[HOST]/app.js`
 
Normally, a Node.js app uses a public folder which you use as the document root. That prevents your code from being exposed in the browser.

Currently, it looks like your Document Root is set to the same location as your Application Root (D:\PROJECT - LIVE\IMS\), which is why app.js and other files are directly accessible via HTTP.

Your public folder only contains static assets (CSS/images). How does your application serve HTML to users? Do you use a template engine (I see .jade files), or is this an API-only application? This will help determine the correct Document Root configuration.

In most cases, setting Document Root to D:\PROJECT - LIVE\IMS\public should solve this issue.
 
If you can't change the document root to \public for whatever reason you should be able to just restrict the access. Since it seems like you're on Windows you're using IIS. You should be able to pull this off by editing the web.config file to add whatever path you don't want people access

XML:
<configuration>
 <system.webServer>
  <security>
   <requestFiltering>
    <hiddenSegments>
     <add segment="Folder"/>
    </hiddenSegments>
   </requestFiltering>
  </security>
 </system.webServer>
</configuration>

Or to block specific extensions only:

XML:
<configuration>
    <system.webServer>
        <security>
            <requestFiltering>
                <fileExtensions>
                    <add fileExtension=".js" allowed="false" />
                </fileExtensions>
            </requestFiltering>
        </security>
    </system.webServer>
</configuration>

If you prefer a GUI approached you can follow the instructions outlined at IIS - ignore/deny access to specific pages (I don't have a windows server so I'm not sure if this can be done natively within Plesk for Windows so you'll need to RDP to the server to set that up).

But honestly you should just do what @Maarten said and just update the document root to \public.
 
Back
Top