Skip to content

fix(common): introduce magic file type validator to nestjs common #14948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 50 commits into from
Apr 14, 2025

Conversation

Chathula
Copy link
Contributor

  • introduce magic file type validator logic to nestjs common with validator class FileTypeValidator

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix

  • Feature

  • Code style update (formatting, local variables)

  • Refactoring (no functional changes, no api changes)

  • Build related changes

  • CI related changes

  • Other... Please describe:

  • security enhancement fix

What is the current behavior?

Issue Number: N/A

What is the new behavior?

  • now user can use addMagicFileTypeValidator pipe method instead of addFileTypeValidator pipe to more secure mime type validation

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Chathula and others added 30 commits April 11, 2025 14:40
@Chathula Chathula changed the title Fix nest common mime validator fix(common): introduce magic file type validator to nestjs common Apr 11, 2025
@kamilmysliwiec kamilmysliwiec merged commit cb0d650 into nestjs:10.4.15 Apr 14, 2025
1 of 2 checks passed
@alumni
Copy link

alumni commented Apr 17, 2025

I'm starting to get this error after updating from 10.4.15 to 10.4.17:

Validation failed (current file type is application/octet-stream, expected type is application/octet-stream)

@flixbusali
Copy link

By no means it was a minor release.

renatosugimoto added a commit to renatosugimoto/ts-nestjs-trainning that referenced this pull request May 21, 2025
![snyk-top-banner](https://res.cloudinary.com/snyk/image/upload/r-d/scm-platform/snyk-pull-requests/pr-banner-default.svg)


<h3>Snyk has created this PR to upgrade @nestjs/platform-express from
10.4.15 to 10.4.17.</h3>

:information_source: Keep your dependencies up-to-date. This makes it
easier to fix existing vulnerabilities and to more quickly identify and
fix newly disclosed vulnerabilities when they affect your project.

<hr/>


- The recommended version is **2 versions** ahead of your current
version.

- The recommended version was released **25 days ago**.

#### Issues fixed by the recommended upgrade:

|  | Issue | Score | Exploit Maturity |

:-------------------------:|:-------------------------|:-------------------------|:-------------------------
![medium
severity](https://res.cloudinary.com/snyk/image/upload/r-d/scm-platform/snyk-pull-requests//severity-medium.svg
'medium severity') | Arbitrary Code
Injection<br/>[SNYK-JS-NESTJSCOMMON-9538801](https://snyk.io/vuln/SNYK-JS-NESTJSCOMMON-9538801)
| **561** | Proof of Concept



<details>
<summary><b>Release notes</b></summary>
<br/>
  <details>
    <summary>Package name: <b>@nestjs/platform-express</b></summary>
    <ul>
      <li>
<b>10.4.17</b> - <a
href="https://redirect.github.com/nestjs/nest/releases/tag/v10.4.17">2025-04-15</a></br><p>v10.4.17</p>
      </li>
      <li>
<b>10.4.16</b> - <a
href="https://redirect.github.com/nestjs/nest/releases/tag/v10.4.16">2025-04-14</a></br><h2>What's
Changed</h2>
<ul>
<li>fix(common): introduce magic file type validator to nestjs common by
<a class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/Chathula/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/Chathula">@ Chathula</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="2988831051" data-permission-text="Title is private"
data-url="nestjs/nest#14948"
data-hovercard-type="pull_request"
data-hovercard-url="/nestjs/nest/pull/14948/hovercard"
href="https://redirect.github.com/nestjs/nest/pull/14948">#14948</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a class="commit-link"
href="https://redirect.github.com/nestjs/nest/compare/v10.4.15...v10.4.16"><tt>v10.4.15...v10.4.16</tt></a></p>
      </li>
      <li>
        <b>10.4.15</b> - 2024-12-09
      </li>
    </ul>
from <a
href="https://redirect.github.com/nestjs/nest/releases">@nestjs/platform-express
GitHub release notes</a>
  </details>
</details>

---

> [!IMPORTANT]
>
> - Check the changes in this PR to ensure they won't cause issues with
your project.
> - This PR was automatically created by Snyk using the credentials of a
real user.
> - Max score is 1000. Note that the real score may have changed since
the PR was raised.
> - Snyk has automatically assigned this pull request, [set who gets
assigned](/settings/integration).

---

**Note:** _You are seeing this because you or someone else with access
to this repository has authorized Snyk to open upgrade PRs._

**For more information:** <img
src="https://api.segment.io/v1/pixel/track?data=eyJ3cml0ZUtleSI6InJyWmxZcEdHY2RyTHZsb0lYd0dUcVg4WkFRTnNCOUEwIiwiYW5vbnltb3VzSWQiOiI0NWRhM2MxMi1jYTlmLTQyNWEtODY3MS00N2E2OTY2NTFkMDQiLCJldmVudCI6IlBSIHZpZXdlZCIsInByb3BlcnRpZXMiOnsicHJJZCI6IjQ1ZGEzYzEyLWNhOWYtNDI1YS04NjcxLTQ3YTY5NjY1MWQwNCJ9fQ=="
width="0" height="0"/>

> - 🧐 [View latest project
report](https://app.snyk.io/org/renatosugimoto/project/31d5132a-e6b1-4b8a-a6a3-43b157a71ac5?utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr)
> - 👩‍💻 [Set who automatically gets
assigned](https://app.snyk.io/org/renatosugimoto/project/31d5132a-e6b1-4b8a-a6a3-43b157a71ac5/settings/integration?utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr/)
> - 📜 [Customise PR
templates](https://docs.snyk.io/scan-using-snyk/pull-requests/snyk-fix-pull-or-merge-requests/customize-pr-templates?utm_source=&utm_content=fix-pr-template)
> - 🛠 [Adjust upgrade PR
settings](https://app.snyk.io/org/renatosugimoto/project/31d5132a-e6b1-4b8a-a6a3-43b157a71ac5/settings/integration?utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr)
> - 🔕 [Ignore this dependency or unsubscribe from future upgrade
PRs](https://app.snyk.io/org/renatosugimoto/project/31d5132a-e6b1-4b8a-a6a3-43b157a71ac5/settings/integration?pkg&#x3D;@nestjs/platform-express&amp;utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr#auto-dep-upgrades)

[//]: #
'snyk:metadata:{"customTemplate":{"variablesUsed":[],"fieldsUsed":[]},"dependencies":[{"name":"@nestjs/platform-express","from":"10.4.15","to":"10.4.17"}],"env":"prod","hasFixes":true,"isBreakingChange":false,"isMajorUpgrade":false,"issuesToFix":["SNYK-JS-NESTJSCOMMON-9538801"],"prId":"45da3c12-ca9f-425a-8671-47a696651d04","prPublicId":"45da3c12-ca9f-425a-8671-47a696651d04","packageManager":"npm","priorityScoreList":[561],"projectPublicId":"31d5132a-e6b1-4b8a-a6a3-43b157a71ac5","projectUrl":"https://app.snyk.io/org/renatosugimoto/project/31d5132a-e6b1-4b8a-a6a3-43b157a71ac5?utm_source=github&utm_medium=referral&page=upgrade-pr","prType":"upgrade","templateFieldSources":{"branchName":"default","commitMessage":"default","description":"default","title":"default"},"templateVariants":["priorityScore"],"type":"auto","upgrade":["SNYK-JS-NESTJSCOMMON-9538801"],"upgradeInfo":{"versionsDiff":2,"publishedDate":"2025-04-15T16:10:28.275Z"},"vulns":["SNYK-JS-NESTJSCOMMON-9538801"]}'

Co-authored-by: snyk-bot <[email protected]>
renatosugimoto added a commit to renatosugimoto/ts-nestjs-trainning that referenced this pull request May 21, 2025
![snyk-top-banner](https://res.cloudinary.com/snyk/image/upload/r-d/scm-platform/snyk-pull-requests/pr-banner-default.svg)


<h3>Snyk has created this PR to upgrade @nestjs/core from 10.4.15 to
10.4.17.</h3>

:information_source: Keep your dependencies up-to-date. This makes it
easier to fix existing vulnerabilities and to more quickly identify and
fix newly disclosed vulnerabilities when they affect your project.

<hr/>


- The recommended version is **2 versions** ahead of your current
version.

- The recommended version was released **25 days ago**.

#### Issues fixed by the recommended upgrade:

|  | Issue | Score | Exploit Maturity |

:-------------------------:|:-------------------------|:-------------------------|:-------------------------
![medium
severity](https://res.cloudinary.com/snyk/image/upload/r-d/scm-platform/snyk-pull-requests//severity-medium.svg
'medium severity') | Arbitrary Code
Injection<br/>[SNYK-JS-NESTJSCOMMON-9538801](https://snyk.io/vuln/SNYK-JS-NESTJSCOMMON-9538801)
| **561** | Proof of Concept



<details>
<summary><b>Release notes</b></summary>
<br/>
  <details>
    <summary>Package name: <b>@nestjs/core</b></summary>
    <ul>
      <li>
<b>10.4.17</b> - <a
href="https://redirect.github.com/nestjs/nest/releases/tag/v10.4.17">2025-04-15</a></br><p>v10.4.17</p>
      </li>
      <li>
<b>10.4.16</b> - <a
href="https://redirect.github.com/nestjs/nest/releases/tag/v10.4.16">2025-04-14</a></br><h2>What's
Changed</h2>
<ul>
<li>fix(common): introduce magic file type validator to nestjs common by
<a class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/Chathula/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/Chathula">@ Chathula</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="2988831051" data-permission-text="Title is private"
data-url="nestjs/nest#14948"
data-hovercard-type="pull_request"
data-hovercard-url="/nestjs/nest/pull/14948/hovercard"
href="https://redirect.github.com/nestjs/nest/pull/14948">#14948</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a class="commit-link"
href="https://redirect.github.com/nestjs/nest/compare/v10.4.15...v10.4.16"><tt>v10.4.15...v10.4.16</tt></a></p>
      </li>
      <li>
        <b>10.4.15</b> - 2024-12-09
      </li>
    </ul>
from <a
href="https://redirect.github.com/nestjs/nest/releases">@nestjs/core
GitHub release notes</a>
  </details>
</details>

---

> [!IMPORTANT]
>
> - Check the changes in this PR to ensure they won't cause issues with
your project.
> - This PR was automatically created by Snyk using the credentials of a
real user.
> - Max score is 1000. Note that the real score may have changed since
the PR was raised.
> - Snyk has automatically assigned this pull request, [set who gets
assigned](/settings/integration).

---

**Note:** _You are seeing this because you or someone else with access
to this repository has authorized Snyk to open upgrade PRs._

**For more information:** <img
src="https://api.segment.io/v1/pixel/track?data=eyJ3cml0ZUtleSI6InJyWmxZcEdHY2RyTHZsb0lYd0dUcVg4WkFRTnNCOUEwIiwiYW5vbnltb3VzSWQiOiIzMzlmMzU4Mi05MTA1LTRlNmMtODI5ZC03Y2Y3MDhlZjMxZmEiLCJldmVudCI6IlBSIHZpZXdlZCIsInByb3BlcnRpZXMiOnsicHJJZCI6IjMzOWYzNTgyLTkxMDUtNGU2Yy04MjlkLTdjZjcwOGVmMzFmYSJ9fQ=="
width="0" height="0"/>

> - 🧐 [View latest project
report](https://app.snyk.io/org/renatosugimoto/project/31d5132a-e6b1-4b8a-a6a3-43b157a71ac5?utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr)
> - 👩‍💻 [Set who automatically gets
assigned](https://app.snyk.io/org/renatosugimoto/project/31d5132a-e6b1-4b8a-a6a3-43b157a71ac5/settings/integration?utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr/)
> - 📜 [Customise PR
templates](https://docs.snyk.io/scan-using-snyk/pull-requests/snyk-fix-pull-or-merge-requests/customize-pr-templates?utm_source=&utm_content=fix-pr-template)
> - 🛠 [Adjust upgrade PR
settings](https://app.snyk.io/org/renatosugimoto/project/31d5132a-e6b1-4b8a-a6a3-43b157a71ac5/settings/integration?utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr)
> - 🔕 [Ignore this dependency or unsubscribe from future upgrade
PRs](https://app.snyk.io/org/renatosugimoto/project/31d5132a-e6b1-4b8a-a6a3-43b157a71ac5/settings/integration?pkg&#x3D;@nestjs/core&amp;utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr#auto-dep-upgrades)

[//]: #
'snyk:metadata:{"customTemplate":{"variablesUsed":[],"fieldsUsed":[]},"dependencies":[{"name":"@nestjs/core","from":"10.4.15","to":"10.4.17"}],"env":"prod","hasFixes":true,"isBreakingChange":false,"isMajorUpgrade":false,"issuesToFix":["SNYK-JS-NESTJSCOMMON-9538801"],"prId":"339f3582-9105-4e6c-829d-7cf708ef31fa","prPublicId":"339f3582-9105-4e6c-829d-7cf708ef31fa","packageManager":"npm","priorityScoreList":[561],"projectPublicId":"31d5132a-e6b1-4b8a-a6a3-43b157a71ac5","projectUrl":"https://app.snyk.io/org/renatosugimoto/project/31d5132a-e6b1-4b8a-a6a3-43b157a71ac5?utm_source=github&utm_medium=referral&page=upgrade-pr","prType":"upgrade","templateFieldSources":{"branchName":"default","commitMessage":"default","description":"default","title":"default"},"templateVariants":["priorityScore"],"type":"auto","upgrade":["SNYK-JS-NESTJSCOMMON-9538801"],"upgradeInfo":{"versionsDiff":2,"publishedDate":"2025-04-15T16:10:28.940Z"},"vulns":["SNYK-JS-NESTJSCOMMON-9538801"]}'

Co-authored-by: snyk-bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants