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.
rack-post-body-to-params
Advanced tools
= Security advice
Rack::PostBodyToParams is affected by every Rails security issue induced by YAML deserialization for HTTP POST bodys as it just uses ActionSupport for that. You should either upgrade ActiveSupport or require the 'safe_yaml' gem. As of version 0.1.6 Rack::PostBodyToParams will prevent you from initializing if the XML parser is unsafe. It defaults to ActiveSupports Hash#from_xml.
= Rack::PostBodyToParams
Parses the POST or PUT body to a Hash and put it into the FORM_HASH. Most frameworks get the params hash from there.
You want to build a XMl or JSON API not with Rails? Perhaps Sinatra[http://www.sinatrarb.com/] or Padrino[http://www.padrinorb.com/]? Are you missing the Rails feature that the body of XML and JSON POST or PUT requests are automatically parsed into the params hash? Here you go!
There is something similar already in the {rack-contrib gem}[http://github.com/rack/rack-contrib] called Rack::PostBodyContentTypeParser. Besides being even less creative with the naming Rack::PostBodyToParams sports these features:
== Howto use
just
gem install rack-post-body-to-params
(sorry for the name ;-)
and then in your config.ru or app.rb:
require 'rack/post-body-to-params' use Rack::PostBodyToParams
or
use Rack::PostBodyContentTypeParser, :content_types => ['application/xml'], :parsers => { 'application/xml' => Proc.new{|a| my_own_xml_parser a }, 'application/foo' => Proc.new{|a| my_foo_parser a } }
As you can see you can restrict Rack::PostBodyToParams to only respond to 'application/xml' or 'application/json'.
Make shure ActiveSupport is required and configured. Should look somewhat like this:
ActiveSupport::JSON.backend = 'Yajl' ActiveSupport::XmlMini.backend = 'Nokogiri'
Note that all current versions of ActiveSupport (up to 3.0.0.beta4) have a bug when requiring the yajl gem. See here for details: {Rails Ticket 4897}[https://rails.lighthouseapp.com/projects/8994/tickets/4897-yajl-backend-discovery-fails-in-activesupportjson].
Either you have to patch your ActiveSupport gem or use another parser:
ActiveSupport::JSON.backend = 'YAML'
== This is early release software. Bug reports and (even more so) fixes are highly welcome!
== Note on Patches/Pull Requests
== Copyright
Copyright (c) 2010 Niko Dittmann. See LICENSE for details.
FAQs
Unknown package
We found that rack-post-body-to-params 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
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.