Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Anything Llm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
Mintplex Labs
Anything Llm
Commits
e1dcd5de
Commit
e1dcd5de
authored
1 year ago
by
timothycarambat
Browse files
Options
Downloads
Patches
Plain Diff
Normalize pfp path to prevent traversal
parent
026849df
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/endpoints/system.js
+3
-2
3 additions, 2 deletions
server/endpoints/system.js
server/utils/files/pfp.js
+2
-2
2 additions, 2 deletions
server/utils/files/pfp.js
with
5 additions
and
4 deletions
server/endpoints/system.js
+
3
−
2
View file @
e1dcd5de
...
@@ -502,7 +502,8 @@ function systemEndpoints(app) {
...
@@ -502,7 +502,8 @@ function systemEndpoints(app) {
}
}
const
userRecord
=
await
User
.
get
({
id
:
user
.
id
});
const
userRecord
=
await
User
.
get
({
id
:
user
.
id
});
const
oldPfpFilename
=
userRecord
.
pfpFilename
;
const
oldPfpFilename
=
normalizePath
(
userRecord
.
pfpFilename
);
console
.
log
(
"
oldPfpFilename
"
,
oldPfpFilename
);
console
.
log
(
"
oldPfpFilename
"
,
oldPfpFilename
);
if
(
oldPfpFilename
)
{
if
(
oldPfpFilename
)
{
const
oldPfpPath
=
path
.
join
(
const
oldPfpPath
=
path
.
join
(
...
@@ -536,7 +537,7 @@ function systemEndpoints(app) {
...
@@ -536,7 +537,7 @@ function systemEndpoints(app) {
try
{
try
{
const
user
=
await
userFromSession
(
request
,
response
);
const
user
=
await
userFromSession
(
request
,
response
);
const
userRecord
=
await
User
.
get
({
id
:
user
.
id
});
const
userRecord
=
await
User
.
get
({
id
:
user
.
id
});
const
oldPfpFilename
=
userRecord
.
pfpFilename
;
const
oldPfpFilename
=
normalizePath
(
userRecord
.
pfpFilename
)
;
console
.
log
(
"
oldPfpFilename
"
,
oldPfpFilename
);
console
.
log
(
"
oldPfpFilename
"
,
oldPfpFilename
);
if
(
oldPfpFilename
)
{
if
(
oldPfpFilename
)
{
const
oldPfpPath
=
path
.
join
(
const
oldPfpPath
=
path
.
join
(
...
...
This diff is collapsed.
Click to expand it.
server/utils/files/pfp.js
+
2
−
2
View file @
e1dcd5de
...
@@ -2,6 +2,7 @@ const path = require("path");
...
@@ -2,6 +2,7 @@ const path = require("path");
const
fs
=
require
(
"
fs
"
);
const
fs
=
require
(
"
fs
"
);
const
{
getType
}
=
require
(
"
mime
"
);
const
{
getType
}
=
require
(
"
mime
"
);
const
{
User
}
=
require
(
"
../../models/user
"
);
const
{
User
}
=
require
(
"
../../models/user
"
);
const
{
normalizePath
}
=
require
(
"
.
"
);
function
fetchPfp
(
pfpPath
)
{
function
fetchPfp
(
pfpPath
)
{
if
(
!
fs
.
existsSync
(
pfpPath
))
{
if
(
!
fs
.
existsSync
(
pfpPath
))
{
...
@@ -32,8 +33,7 @@ async function determinePfpFilepath(id) {
...
@@ -32,8 +33,7 @@ async function determinePfpFilepath(id) {
const
basePath
=
process
.
env
.
STORAGE_DIR
const
basePath
=
process
.
env
.
STORAGE_DIR
?
path
.
join
(
process
.
env
.
STORAGE_DIR
,
"
assets/pfp
"
)
?
path
.
join
(
process
.
env
.
STORAGE_DIR
,
"
assets/pfp
"
)
:
path
.
join
(
__dirname
,
"
../../storage/assets/pfp
"
);
:
path
.
join
(
__dirname
,
"
../../storage/assets/pfp
"
);
const
pfpFilepath
=
path
.
join
(
basePath
,
pfpFilename
);
const
pfpFilepath
=
path
.
join
(
basePath
,
normalizePath
(
pfpFilename
));
if
(
!
fs
.
existsSync
(
pfpFilepath
))
return
null
;
if
(
!
fs
.
existsSync
(
pfpFilepath
))
return
null
;
return
pfpFilepath
;
return
pfpFilepath
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment