Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
A mini-FTP server framework built on top of the EventMacine gem. By providing a simple driver class that responds to a handful of methods you can have a complete FTP server.
The library is extracted from real world situations where an FTP interface was required to sit in front of a non-filesystem persistence layer.
Some sample use cases include persisting data to:
For some examples that demonstrate redis and memory persistence, check the examples/ directory.
To boot an FTP server you will need to provide a driver that speaks to your persistence layer.
Create a config.rb file that loads the driver and then configures the server
require 'my_fancy_driver'
driver MyFancyDriver
user 'ftp'
group 'ftp'
Run your server like so:
em-ftpd config.rb
Valid options for the config file are:
The driver MUST have the following methods. Each method MUST accept a block and yield the appropriate value:
authenticate(user, pass, &block)
- boolean indicating if the provided details are valid
bytes(path, &block)
- an integer with the number of bytes in the file or nil if the file
doesn't exist
change_dir(path, &block)
- a boolen indicating if the current user is permitted to change to the
requested path
dir_contents(path, &block)
- an array of the contents of the requested path or nil if the dir
doesn't exist. Each entry in the array should be
EM::FTPD::DirectoryItem-ish
delete_dir(path, &block)
- a boolean indicating if the directory was successfully deleted
delete_file(path, &block)
- a boolean indicating if path was successfully deleted
rename(from_path, to_path, &block)
- a boolean indicating if from_path was successfully renamed to to_path
make_dir(path, &block)
- a boolean indicating if path was successfully created as a new directory
get_file(path, &block)
- nil if the user isn't permitted to access that path
- an IOish (File, StringIO, IO, etc) object with data to send back to the
client
- a string with the file data to send to the client
- an array of strings to join with the standard FTP line break and send to
the client
The driver MUST have one of the following methods. Each method MUST accept a block and yield the appropriate value:
put_file(path, tmp_file_path, &block)
- an integer indicating the number of bytes received or False if there
was an error
put_file_streamed(path, datasocket, &block)
- an integer indicating the number of bytes received or False if there
was an error
James Healy james@yob.id.au http://www.yob.id.au John Nunemaker nunemaker@gmail.com Elijah Miller elijah.miller@gmail.com
FTP is an incredibly insecure protocol. Be careful about forcing users to authenticate with a username or password that are important.
This library is distributed under the terms of the MIT License. See the included file for more detail.
All suggestions and patches welcome, preferably via a git repository I can pull from. If this library proves useful to you, please let me know.
There are a range of RFCs that together specify the FTP protocol. In chronological order, the more useful ones are:
For an english summary that's somewhat more legible than the RFCs, and provides some commentary on what features are actually useful or relevant 24 years after RFC959 was published:
For a history lesson, check out Appendix III of RCF959. It lists the preceding (obsolete) RFC documents that relate to file transfers, including the ye old RFC114 from 1971, "A File Transfer Protocol"
For more information on EventMacine, a library that (among other things) simplifies writing applications that use sockets, check out their website.
FAQs
Unknown package
We found that em-ftpd demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.