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.
To compile the agent and its dependencies:
bundle exec rake build
Add the private Immunio gem to your Gemfile:
gem 'immunio'
Run Bundler to install the gem:
bundle install
Note that if your application is not using Bundler, require the Immunio package:
require 'immunio'
The agent key and secret can be configured in a configuration file at config/immunio.yml.
Optionally, the agent key and secret can be set using the IMMUNIO_KEY
and IMMUNIO_SECRET
environment variables, which will take precedence.
key: "my-key"
secret: "my-secret"
The Immunio agent is enabled by default in all rails environments. It can be enabled in production only in your Gemfile:
gem immunio', group: :production
You can also modify the secret and key for different environments to report to different apps, or you can disable the agent by setting agent_enabled: false
in the configuration or IMMUNIO_AGENT_ENABLED=0
in the environment.
In order for the agent to function correctly in a pre-forked environment, use the Immunio.reset!
method.
For example, in your config/unicorn.rb
:
after_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
end
defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
Immunio.reset!
end
By default, Immunio will return a plain text 403 Forbidden response whenever it blocks a request for security reasons.
To customize this behavior, use the Immunio.blocked_app
option, which should be a valid Rack application:
Immunio.blocked_app = -> env do
[
403,
{ 'Content-Type' => 'text/html' },
ActionController::DataStreaming::FileBody.new('public/403.html')
]
end
If you're using Devise or Authlogic, Immunio will automatically hook into your authentication system to protect you against attacks.
If you're not using one of the above frameworks, you will need to manually tell Immunio when authentication occurs. Use the following methods to do so.
Immunio.login user
Immunio.failed_login
Immunio.logout
Immunio.set_user
Immunio.password_reset
Immunio.failed_password_reset
Note: Immunio.set_user
should be called for every request where user data is available, not just when authentication mechanisms are used.
These methods take an options hash with the following information:
Here's an example:
class ApplicationController
def current_user=(user)
Immunio.set_user user_record: user
# Store user ...
end
end
class SessionsController < ApplicationController
# POST /login
def create
if user = User.authenticate(params[:user])
Immunio.login user_record: user
self.current_user = user
# ...
else
Immunio.failed_login username: params[:user]
# ...
end
end
# DELETE /logout
def destroy
Immunio.logout user_record: current_user
# ...
end
end
FAQs
Unknown package
We found that immunio 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.