Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
This is a simple but very configurable FTP server. Notable features include:
fs
module, so you can use any implementation,
even on a per-user basis. This makes it possible for each user to have
his/her own virtual file system, isolated from that of the system or other
users.npm install ftpd
See example code in test.js
host is a string representation of the IP address clients use to connect to the FTP server. It's imperative that this actually reflects the remote IP the clients use to access the server, as this IP will be used in the establishment of PASV data connections. If this IP is not the one clients use to connect, you will see some strange behavior from the client side (hangs).
See test.js
for a simple example. FtpServer
accepts the following options:
Both these need to be set - there are no defaults.
getInitialCwd
: Gets the initial working directory for the user. Called after user is authenticated.
This path is relative to the root directory. The user may escape their initial cwd.
Pattern: function(username, [callback(err, path)])
Arguments:
Examples:
getInitialCwd: function(connection) {
return "/" + connection.username;
}
getInitialCwd: function(connection, callback) {
var userDir = '/' + connection.username;
fs.exists(userDir, function(exists) {
if (exists) {
callback(null, userDir);
} else {
fs.mkDir(userDir, function(err) {
callback(err, userDir);
});
}
});
}
// If the directory exists, callback immediately with that directory
// If not, create the directory and callback possible error + directory
getRoot
: Gets the root directory for the user. This directory has the path '/' from the point of view of the user.
The user is not able to escape this directory.
Pattern: function(connection, [callback(err, rootPath)])
Arguments:
Examples:
getRoot: function() {
return process.cwd();
}
// The users will now enter at the '/' level, which is the directory passed to getInitialCwd.
getRoot: function(connection, callback) {
var rootPath = process.cwd() + '/' + connection.username;
fs.exists(rootPath, function(exists) {
if (exists) {
callback(null, rootPath);
} else {
fs.mkDir(userDir, function(err) {
if (err) {
callback(null, '/'); // default to root
} else {
callback(err, rootPath);
}
});
}
});
}
// If the subdir exists, callback immediately with relative path to that directory
// If not, create the directory, and callback relative path to the directory
// Stupidly, instead of failing, we apparently want 'worst case' scenario to allow relative root.
useWriteFile
: (default: false)
true
, then files which the client uploads are buffered in memory and then written to disk using writeFile
.false
, files are written using writeStream.useReadFile
: (default: false)
true
, then files which the client downloads are slurped using 'readFile'.false
, files are read using readStream.uploadMaxSlurpSize
: (default: unlimited)
useWriteFile
is set to true
.uploadMaxSlurpSize
is not set, then there is no limit on buffer size.hideDotFiles
: (default: false)
LIST
commands.maxStatsAtOnce
: (default: 5)
fs.stat
which will be
made when processing a LIST
request.filenameSortFunc
: (default: localeCompare
)
sort
method. Used to sort filenames for directory listings.filenameSortMap
: (default: function (x) { return x.toUpperCase() }
)
false
, filenames are unaltered.dontSortFilenames
: (default: false)
LIST
and NLST
commands.noWildcards
: (default: false)
true
, then LIST
and NLST
treat the characters ?
and *
as literals instead of as wildcards.allowedCommands
: (default: undefined)
tlsOptions
: (default: undefined)
options
argument of tls.createServer
.tlsOnly
: (default: false)
true
, and tlsOptions
is also set, then the server will not allow logins over non-secure connections.allowUnauthorizedTls
: ?? I obviously set this to true when tlsOnly is on -someone needs to update this.pasvPortRangeStart
: (default: random?)
pasvPortRangeEnd
: (default: random?)
Filesystem abstraction makes it possible to create an FTP server which interacts directly with a database rather than the actual filesystem.
The server raises a command:pass
event which is given pass
, success
and
failure
arguments. On successful login, success
should be called with a
username argument. It may also optionally be given a second argument, which
should be an object providing an implementation of the API for Node's fs
module.
The following must be implemented:
unlink
readdir
mkdir
open
close
rmdir
rename
stat
→
{ mode, isDirectory(), size, mtime }
useWriteFile
option is not set or is false
createWriteStream
: Returns a writable stream, requiring:
useWriteFile
option is set to 'true'
writeFile
useReadFile
option is not set or is false
createReadStream
: Returns a readable stream, requiring:
useReadFile
option is set to 'true'
readFile
FtpServer
has listen
and close
methods which behave as expected. It
emits close
and error
events.
FAQs
Node FTP Server
We found that ftpd demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.