code
stringlengths
12
2.05k
label
int64
0
1
programming_language
stringclasses
9 values
cwe_id
stringlengths
6
14
cwe_name
stringlengths
5
103
description
stringlengths
36
1.23k
url
stringlengths
36
48
label_name
stringclasses
2 values
def digest_algorithm; Digest(:SHA512); end
1
Ruby
CWE-347
Improper Verification of Cryptographic Signature
The software does not verify, or incorrectly verifies, the cryptographic signature for data.
https://cwe.mitre.org/data/definitions/347.html
safe
def read_lines(path, selector) if selector IO.foreach(path).select.with_index(1, &selector) else URI.open(path, &:read) end end
0
Ruby
CWE-78
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/78.html
vulnerable
it "should reject a wildcard subjectAltName" do @request.stubs(:subject_alt_names).returns ['DNS:foo', 'DNS:*.bar'] expect { @ca.check_internal_signing_policies(@name, @request, true) }.to raise_error( Puppet::SSL::CertificateAuthority::CertificateSigningError, /subjectAltName contains a wildcard/ ) end
1
Ruby
CWE-264
Permissions, Privileges, and Access Controls
Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.
https://cwe.mitre.org/data/definitions/264.html
safe
def test_execute_details_cleans_text spec_fetcher do |fetcher| fetcher.spec 'a', 2 do |s| s.summary = 'This is a lot of text. ' * 4 s.authors = ["Abraham Lincoln \x01", "\x02 Hirohito"] s.homepage = "http://a.example.com/\x03" end fetcher.legacy_platform end @cmd.handle_options %w[-r -d] use_ui @ui do @cmd.execute end expected = <<-EOF *** REMOTE GEMS *** a (2) Authors: Abraham Lincoln ., . Hirohito Homepage: http://a.example.com/. This is a lot of text. This is a lot of text. This is a lot of text. This is a lot of text. pl (1) Platform: i386-linux Author: A User Homepage: http://example.com this is a summary EOF assert_equal expected, @ui.output assert_equal '', @ui.error end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def email_verify_send raise Exceptions::UnprocessableEntity, 'No email!' if !params[:email] user = User.find_by(email: params[:email].downcase) if !user # result is always positive to avoid leaking of existing user accounts render json: { message: 'ok' }, status: :ok return end #if user.verified == true # render json: { error: 'Already verified!' }, status: :unprocessable_entity # return #end Token.create(action: 'Signup', user_id: user.id) result = User.signup_new_token(user) if result && result[:token] user = result[:user] NotificationFactory::Mailer.notification( template: 'signup', user: user, objects: result ) # only if system is in develop mode, send token back to browser for browser tests if Setting.get('developer_mode') == true render json: { message: 'ok', token: result[:token].name }, status: :ok return end # token sent to user, send ok to browser render json: { message: 'ok' }, status: :ok return end # unable to generate token render json: { message: 'failed' }, status: :ok end
0
Ruby
CWE-863
Incorrect Authorization
The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.
https://cwe.mitre.org/data/definitions/863.html
vulnerable
it "returns the document" do session.simple_query(query).should eq(a: 1) end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def get_auth_teams Log.add_info(request, params.inspect) begin @folder = Folder.find(params[:id]) rescue @folder = nil end target_user_id = (@login_user.admin?(User::AUTH_TEAM))?(nil):(@login_user.id) @teams = Team.get_for(target_user_id, true) session[:folder_id] = params[:id] render(:partial => 'ajax_auth_teams', :layout => false) end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def __bson_dump__(io, key) io << Types::OBJECT_ID io << key io << NULL_BYTE io << data end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def cluster_disable(params, request, session) if params[:name] code, response = send_request_with_token( session, params[:name], 'cluster_disable', true ) else if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end success = disable_cluster(session) if not success return JSON.generate({"error" => "true"}) end return "Cluster Disabled" end end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def team_organize Log.add_info(request, params.inspect) team_id = params[:team_id] unless team_id.nil? or team_id.empty? begin @team = Team.find(team_id) rescue @team = nil ensure if @team.nil? flash[:notice] = t('msg.already_deleted', :name => Team.model_name.human) return end end users = @team.get_users_a end team_members = params[:team_members] created = false modified = false if team_members.nil? or team_members.empty? unless team_id.nil? or team_id.empty? # @team must not be nil. @team.save if modified = @team.clear_users end else if team_members != users if team_id.nil? or team_id.empty? item = Item.find(params[:id]) created = true @team = Team.new @team.name = item.title @team.item_id = params[:id] @team.status = Team::STATUS_STANDBY else @team.clear_users end @team.add_users team_members @team.save @team.remove_application team_members modified = true end end if created @team.create_team_folder end @item = @team.item if modified flash[:notice] = t('msg.register_success') end render(:partial => 'ajax_team_info', :layout => false) rescue => evar Log.add_error(request, evar) render(:partial => 'ajax_team_info', :layout => false) end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def self.run_gpg(*args) fragments = [ 'gpg', '--no-default-keyring' ] + args command_line = fragments.collect { |fragment| Shellwords.escape(fragment) }.join(' ') output_file = Tempfile.new('gpg-output') begin output_file.close result = system("#{command_line} > #{Shellwords.escape(output_file.path)} 2>&1") ensure output_file.unlink end raise RuntimeError.new('gpg failed') unless result end
1
Ruby
CWE-94
Improper Control of Generation of Code ('Code Injection')
The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.
https://cwe.mitre.org/data/definitions/94.html
safe
it "should send an email with a return-path using exim" do Mail.defaults do delivery_method :exim end mail = Mail.new do to "[email protected]" from "[email protected]" sender "[email protected]" subject "Can't set the return-path" return_path "[email protected]" message_id "<[email protected]>" body "body" end Mail::Exim.should_receive(:call).with('/usr/sbin/exim', '-i -t -f "[email protected]"', '[email protected]', mail) mail.deliver end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def set_attachment Log.add_info(request, params.inspect) created = false if params[:id].nil? or params[:id].empty? @item = Item.new_info(0) @item.attributes = params[:item] @item.user_id = @login_user.id @item.title = t('paren.no_title') [:attachment0, :attachment1].each do |attach| next if params[attach].nil? or params[attach][:file].nil? or params[attach][:file].size == 0 @item.save! created = true break end else @item = Item.find(params[:id]) end modified = false item_attachments = @item.attachments_without_content [:attachment0, :attachment1].each do |attach| next if params[attach].nil? or params[attach][:file].nil? or params[attach][:file].size == 0 attachment = Attachment.create(params[attach], @item, item_attachments.length) modified = true item_attachments << attachment end if modified and !created @item.update_attribute(:updated_at, Time.now) end render(:partial => 'ajax_item_attachment', :layout => false) rescue => evar Log.add_error(request, evar) @attachment = Attachment.new @attachment.errors.add_to_base(evar.to_s[0, 256]) render(:partial => 'ajax_item_attachment', :layout => false) end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
it "does not drop other indexes" do indexes[age: -1].should_not be_nil end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def diff(path, identifier_from, identifier_to=nil) hg_args = %w|rhdiff| if identifier_to hg_args << '-r' << hgrev(identifier_to) << '-r' << hgrev(identifier_from) else hg_args << '-c' << hgrev(identifier_from) end unless path.blank? p = scm_iconv(@path_encoding, 'UTF-8', path) hg_args << '--' << CGI.escape(hgtarget(p)) end diff = [] hg *hg_args do |io| io.each_line do |line| diff << line end end diff rescue HgCommandAborted nil # means not found end
1
Ruby
NVD-CWE-noinfo
null
null
null
safe
def create Log.add_info(request, '') # Not to show passwords. return unless request.post? if params[:mail_account][:smtp_auth].nil? or params[:mail_account][:smtp_auth] != '1' params[:mail_account].delete(:smtp_username) params[:mail_account].delete(:smtp_password) end @mail_account = MailAccount.new(params.require(:mail_account).permit(MailAccount::PERMIT_BASE)) @mail_account.user_id = @login_user.id @mail_account.is_default = true begin @mail_account.save! rescue if request.xhr? render(:partial => 'mail_account_error', :layout => false) else redirect_to(:controller => 'mail_folders', :action => 'show_tree') end return end flash[:notice] = t('msg.register_success') if request.xhr? render(:partial => 'common/flash_notice', :layout => false) else redirect_to(:controller => 'mail_folders', :action => 'show_tree') end end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def write!(headers) if @orig_disable_profiling != @disable_profiling || @orig_backtrace_level != @backtrace_level || @cookie.nil? settings = {"p" => "t" } settings["dp"] = "t" if @disable_profiling settings["bt"] = @backtrace_level if @backtrace_level settings_string = settings.map{|k,v| "#{k}=#{v}"}.join(",") Rack::Utils.set_cookie_header!(headers, COOKIE_NAME, :value => settings_string, :path => '/') end end
0
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
vulnerable
def team_organize Log.add_info(request, params.inspect) return unless request.post? team_id = params[:team_id] unless team_id.blank? begin @team = Team.find(team_id) rescue @team = nil end if @team.nil? flash[:notice] = t('msg.already_deleted', :name => Team.model_name.human) return end users = @team.get_users_a end team_members = params[:team_members] SqlHelper.validate_token([team_members]) created = false modified = false if team_members.nil? or team_members.empty? unless team_id.blank? # @team must not be nil. modified = @team.clear_users @team.save if modified end else if team_members != users if team_id.blank? item = Item.find(params[:id]) created = true @team = Team.new @team.name = item.title @team.item_id = params[:id] @team.status = Team::STATUS_STANDBY else @team.clear_users end @team.add_users(team_members) @team.save @team.remove_application(team_members) modified = true end end if created @team.create_team_folder end @item = @team.item if modified flash[:notice] = t('msg.register_success') end render(:partial => 'ajax_team_info', :layout => false) rescue => evar Log.add_error(request, evar) render(:partial => 'ajax_team_info', :layout => false) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it "does not change the original session's options" do original_options = options.dup session.with(new_options) do |new_session| session.options.should eql original_options end end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def test_create_valid AuthSourceLdap.any_instance.stubs(:valid?).returns(true) post :create, {:auth_source_ldap => {:name => AuthSourceLdap.first.name}}, set_session_user assert_redirected_to auth_source_ldaps_url end
0
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
vulnerable
it "downloads a file" do expect(subject.download(uri).file.read).to eq file end
0
Ruby
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
it "initializes with the strings bytes" do Moped::BSON::ObjectId.should_receive(:new).with(bytes) Moped::BSON::ObjectId.from_string "4e4d66343b39b68407000001" end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def install_location filename, destination_dir # :nodoc: raise Gem::Package::PathError.new(filename, destination_dir) if filename.start_with? '/' destination_dir = File.realpath destination_dir if File.respond_to? :realpath destination_dir = File.expand_path destination_dir destination = File.join destination_dir, filename destination = File.expand_path destination raise Gem::Package::PathError.new(destination, destination_dir) unless destination.start_with? destination_dir destination.untaint destination end
0
Ruby
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
https://cwe.mitre.org/data/definitions/22.html
vulnerable
def _process_user_attrs(user, attrs) if attrs[:birthday].nil? begin attrs[:birthday] = attrs[:birthday_y] + '-' + attrs[:birthday_m] + '-' + attrs[:birthday_d] rescue end attrs.delete(:birthday_y) attrs.delete(:birthday_m) attrs.delete(:birthday_d) end if !attrs[:name].nil? or !attrs[:password].nil? user_name = attrs[:name] user_name ||= user.name unless user.nil? password = attrs[:password] if password.nil? or password.empty? password = UsersHelper.generate_password attrs[:password] = password end attrs[:pass_md5] = UsersHelper.generate_digest_pass(user_name, password) end return attrs end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
it "returns the database from the options" do session.current_database.should eq(database) end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def digest_match?(data, digest) return unless data && digest @secrets.any? do |secret| digest == generate_hmac(data, secret) end end
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
def config_backup(params, request, session) if params[:name] code, response = send_request_with_token( session, params[:name], 'config_backup', true ) else if not allowed_for_local_cluster(session, Permissions::FULL) return 403, 'Permission denied' end $logger.info "Backup node configuration" stdout, stderr, retval = run_cmd(session, PCS, "config", "backup") if retval == 0 $logger.info "Backup successful" return [200, stdout] end $logger.info "Error during backup: #{stderr.join(' ').strip()}" return [400, "Unable to backup node: #{stderr.join(' ')}"] end end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def mapped_content_type Paperclip.options[:content_type_mappings][filename_extension] end
1
Ruby
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
def self.count_ack_users(item_id) SqlHelper.validate_token([item_id]) return Comment.where("(item_id=#{item_id}) and (xtype='#{Comment::XTYPE_DIST_ACK}')").count end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def update(database, collection, selector, change, options = {}) process Protocol::Update.new(database, collection, selector, change, options) end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
it "skips +n+ documents" do users.insert(documents) users.find(scope: scope).skip(1).to_a.should eq [documents.last] end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def yaml YAML.load(body) end
0
Ruby
CWE-264
Permissions, Privileges, and Access Controls
Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.
https://cwe.mitre.org/data/definitions/264.html
vulnerable
it "to json" do expect(user.to_json).to eql([user.name].to_json) end
1
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
safe
it "adds the server to the list" do cluster.sync_server server cluster.servers.should include server end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
it "raises an error when trying to download a local file" do expect { subject.download('/etc/passwd') }.to raise_error(CarrierWave::DownloadError) end
0
Ruby
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
it "fails when user is suspended" do user.update!( suspended_till: 2.days.from_now, suspended_at: Time.zone.now ) get "/session/email-login/#{email_token.token}" expect(response.status).to eq(200) expect(CGI.unescapeHTML(response.body)).to include(I18n.t("login.suspended", date: I18n.l(user.suspended_till, format: :date_only) )) end
0
Ruby
CWE-287
Improper Authentication
When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.
https://cwe.mitre.org/data/definitions/287.html
vulnerable
def test_destroy auth_source_ldap = AuthSourceLdap.unscoped.first User.unscoped.where(:auth_source_id => auth_source_ldap.id).update_all(:auth_source_id => nil) delete :destroy, {:id => auth_source_ldap}, set_session_user assert_redirected_to auth_source_ldaps_url refute AuthSourceLdap.unscoped.exists?(auth_source_ldap.id) end
1
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
safe
it "yields each document" do users.insert(documents) users.find(scope: scope).each.with_index do |document, index| document.should eq documents[index] end end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def self.destroy_by_user(user_id, add_con=nil) SqlHelper.validate_token([user_id]) con = "(user_id=#{user_id.to_i})" con << " and (#{add_con})" unless add_con.nil? or add_con.empty? mail_accounts = MailAccount.where(con).to_a mail_accounts.each do |mail_account| mail_account.destroy end end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def update Log.add_info(request, '') # Not to show passwords. return unless request.post? @user = User.find(params[:id]) attrs = _process_user_attrs(@user, params[:user]) attrs.delete(:password) # Official title and order to display title = attrs[:title] unless title.nil? attrs[:xorder] = User::XORDER_MAX titles = User.get_config_titles if !titles.nil? and titles.include?(title) attrs[:xorder] = titles.index(title) end end if @user.update_attributes(attrs.except(:id).permit(User::PERMIT_BASE)) flash[:notice] = t('msg.update_success') if @user.id == @login_user.id @login_user = @user end if params[:from] == 'users_list' redirect_to(:controller => 'users', :action => 'list') else redirect_to(:controller => 'desktop', :action => 'show') end else render(:controller => 'users', :action => 'edit') end end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it "creates an index with the extra options" do indexes.create({name: 1}, {unique: true, dropDups: true}) index = indexes[name: 1] index["unique"].should be_true index["dropDups"].should be_true end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
it "should use a certificate type of :ca" do Puppet::SSL::CertificateFactory.expects(:build).with do |*args| args[0] == :ca end.returns "my real cert" @ca.sign(@name, :ca, @request) end
0
Ruby
CWE-264
Permissions, Privileges, and Access Controls
Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.
https://cwe.mitre.org/data/definitions/264.html
vulnerable
def test_update_valid Domain.any_instance.stubs(:valid?).returns(true) put :update, {:id => @model.to_param, :domain => {:name => @model.name }}, set_session_user assert_redirected_to domains_url end
1
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
safe
def list Log.add_info(request, params.inspect) con = [] @group_id = nil if !params[:thetisBoxSelKeeper].nil? @group_id = params[:thetisBoxSelKeeper].split(':').last elsif !params[:group_id].blank? @group_id = params[:group_id] end unless @group_id.nil? if @group_id == '0' con << "((groups like '%|0|%') or (groups is null))" else con << SqlHelper.get_sql_like([:groups], "|#{@group_id}|") end end where = '' unless con.empty? where = ' where ' + con.join(' and ') end order_by = nil @sort_col = params[:sort_col] @sort_type = params[:sort_type] if @sort_col.blank? or @sort_type.blank? @sort_col = 'id' @sort_type = 'ASC' end SqlHelper.validate_token([@sort_col, @sort_type]) order_by = ' order by ' + @sort_col + ' ' + @sort_type sql = 'select distinct Equipment.* from equipment Equipment' sql << where + order_by @equipment_pages, @equipment, @total_num = paginate_by_sql(Equipment, sql, 20) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def query(query) if options[:consistency] == :eventual query.flags |= [:slave_ok] if query.respond_to? :flags mode = :read else mode = :write end reply = socket_for(mode).execute(query) reply.tap do |reply| if reply.flags.include?(:query_failure) raise Errors::QueryFailure.new(query, reply.documents.first) end end end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def notify Log.add_info(request, params.inspect) return unless request.post? root_url = ApplicationHelper.root_url(request) count = UsersHelper.send_notification(params[:check_user], params[:thetisBoxEdit], root_url) if count > 0 flash[:notice] = t('user.notification_sent')+ count.to_s + t('user.notification_sent_suffix') end redirect_to(:action => 'users') end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def set_configs(params, request, session) if not allowed_for_local_cluster(session, Permissions::FULL) return 403, 'Permission denied' end return JSON.generate({'status' => 'bad_json'}) if not params['configs'] begin configs_json = JSON.parse(params['configs']) rescue JSON::ParserError return JSON.generate({'status' => 'bad_json'}) end has_cluster = !($cluster_name == nil or $cluster_name.empty?) if has_cluster and $cluster_name != configs_json['cluster_name'] return JSON.generate({'status' => 'wrong_cluster_name'}) end $semaphore_cfgsync.synchronize { force = configs_json['force'] remote_configs, unknown_cfg_names = Cfgsync::sync_msg_to_configs(configs_json) local_configs = Cfgsync::get_configs_local result = {} unknown_cfg_names.each { |name| result[name] = 'not_supported' } remote_configs.each { |name, remote_cfg| begin # Save a remote config if it is a newer version than local. If the config # is not present on a local node, the node is beeing added to a cluster, # so we need to save the config as well. if force or not local_configs.key?(name) or remote_cfg > local_configs[name] local_configs[name].class.backup() if local_configs.key?(name) remote_cfg.save() result[name] = 'accepted' elsif remote_cfg == local_configs[name] # Someone wants this node to have a config that it already has. # So the desired state is met and the result is a success then. result[name] = 'accepted' else result[name] = 'rejected' end rescue => e $logger.error("Error saving config '#{name}': #{e}") result[name] = 'error' end } return JSON.generate({'status' => 'ok', 'result' => result}) } end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def check_auth(params, request, session) if params.include?("check_auth_only") return [200, "{\"success\":true}"] end return JSON.generate({ 'success' => true, 'node_list' => get_token_node_list, }) end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def authorized?(request) terminus = get_terminus(request) if terminus.respond_to?(:authorized?) terminus.authorized?(request) else true end end
1
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
safe
def resource_stop(params, request, session) if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end stdout, stderr, retval = run_cmd( session, PCS, "resource", "disable", params[:resource] ) if retval == 0 return JSON.generate({"success" => "true"}) else return JSON.generate({"error" => "true", "stdout" => stdout, "stderror" => stderr}) end end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def __bson_load__(io) from_data(io.read(12)) end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
it "updates all matching documents" do users.insert(documents) users.find(scope: scope).update_all("$set" => { "updated" => true }) users.find(scope: scope, updated: true).count.should eq 2 end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def test_sanitize_script assert_sanitized "a b c<script language=\"Javascript\">blah blah blah</script>d e f", "a b cd e f" end
0
Ruby
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
def test_formats_valid AuthSourceLdap.any_instance.stubs(:valid?).returns(false) put :update, {:id => AuthSourceLdap.first.id, :format => "weird", :auth_source_ldap => {:name => AuthSourceLdap.first.name} }, set_session_user assert_response :success wierd_id = "#{AuthSourceLdap.first.id}.weird" put :update, {:id => wierd_id, :auth_source_ldap => {:name => AuthSourceLdap.first.name} }, set_session_user assert_response :success parameterized_id = "#{AuthSourceLdap.first.id}-#{AuthSourceLdap.first.name.parameterize}" put :update, {:id => parameterized_id, :auth_source_ldap => {:name => AuthSourceLdap.first.name} }, set_session_user assert_response :success end
0
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
vulnerable
def remove(server) servers.delete(server) end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def pipeline Threaded.begin :pipeline begin yield ensure Threaded.end :pipeline end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
it "stores the list of seeds" do cluster.seeds.should eq ["127.0.0.1:27017", "127.0.0.1:27018"] end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def self.get_group_value(group_id, category, key) SqlHelper.validate_token([group_id, category, key]) con = [] con << "(group_id=#{group_id})" con << "(category='#{category}')" con << "(xkey='#{key}')" setting = Setting.where(con.join(' and ')).first return setting.xvalue unless setting.nil? return nil end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def index @applications = Doorkeeper.config.application_model.authorized_for(current_resource_owner) respond_to do |format| format.html format.json { render json: @applications } end end
0
Ruby
CWE-862
Missing Authorization
The software does not perform an authorization check when an actor attempts to access a resource or perform an action.
https://cwe.mitre.org/data/definitions/862.html
vulnerable
def delete_attachment Log.add_info(request, '') # Not to show passwords. return unless request.post? target_user = nil user_id = params[:user_id] zeptair_id = params[:zeptair_id] attachment_id = params[:attachment_id] SqlHelper.validate_token([user_id, zeptair_id, attachment_id]) unless user_id.blank? if @login_user.admin?(User::AUTH_ZEPTAIR) or @login_user.id.to_s == user_id.to_s target_user = User.find(user_id) end end unless zeptair_id.blank? target_user = User.where("zeptair_id=#{zeptair_id}").first unless @login_user.admin?(User::AUTH_ZEPTAIR) or @login_user.id == target_user.id target_user = nil end end if target_user.nil? if attachment_id.blank? query unless @post_items.nil? @post_items.each do |post_item| post_item.attachments_without_content.each do |attach| attach.destroy end post_item.update_attribute(:updated_at, Time.now) end end else attach = Attachment.find(attachment_id) item = Item.find(attach.item_id) if !@login_user.admin?(User::AUTH_ZEPTAIR) and item.user_id != @login_user.id raise t('msg.need_to_be_owner') end if item.xtype != Item::XTYPE_ZEPTAIR_POST raise t('msg.system_error') end attach.destroy item.update_attribute(:updated_at, Time.now) end else post_item = ZeptairPostHelper.get_item_for(target_user) post_item.attachments_without_content.each do |attach| attach.destroy end post_item.update_attribute(:updated_at, Time.now) end render(:text => t('msg.delete_success')) rescue => evar Log.add_error(request, evar) render(:text => 'ERROR:' + t('msg.system_error')) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def add_package_kind( kinds ) check_write_access! private_set_package_kind( kinds, nil, true ) end
1
Ruby
CWE-275
Permission Issues
Weaknesses in this category are related to improper assignment or handling of permissions.
https://cwe.mitre.org/data/definitions/275.html
safe
it 'fails when local logins is disabled' do SiteSetting.enable_local_logins = false get "/session/email-login/#{email_token.token}" expect(response.status).to eq(500) end
0
Ruby
CWE-287
Improper Authentication
When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.
https://cwe.mitre.org/data/definitions/287.html
vulnerable
it "returns true" do Moped::BSON::ObjectId.new(bytes).should == Moped::BSON::ObjectId.new(bytes) end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def sync known = known_addresses.shuffle seen = {} sync_seed = ->(seed) do server = Server.new seed unless seen[server.resolved_address] seen[server.resolved_address] = true hosts = sync_server(server) hosts.each do |host| sync_seed[host] end end end known.each do |seed| sync_seed[seed] end unless servers.empty? @dynamic_seeds = servers.map(&:address) end true end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
it "should use the base name of the file name to prevent file system traversal" do Mail.defaults do delivery_method :file, :location => tmpdir end Mail.deliver do from '[email protected]' to '../../../../../../../../../../../tmp/pwn' subject 'evil hacker' end delivery = File.join(Mail.delivery_method.settings[:location], 'pwn') File.exists?(delivery).should be_true end
1
Ruby
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
https://cwe.mitre.org/data/definitions/22.html
safe
def self.get_from_name(user_name) SqlHelper.validate_token([user_name]) begin user = User.where(name: user_name).first rescue => evar Log.add_error(nil, evar) end return user end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def self.normalize_key_names(options) options = options.dup if options.key?(:key_prefix) && !options.key?(:namespace) options[:namespace] = options.delete(:key_prefix) # RailsSessionStore end options[:raw] = !options[:marshalling] options end
0
Ruby
CWE-502
Deserialization of Untrusted Data
The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
def disconnect auth.clear connection.disconnect end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def self.get_for_group(group_id, category=nil) SqlHelper.validate_token([group_id, category]) con = [] con << "(group_id=#{group_id})" con << "(category='#{category}')" unless category.nil? settings = Setting.where(con.join(' and ')).to_a return nil if settings.nil? or settings.empty? hash = Hash.new settings.each do |setting| hash[setting.xkey] = setting.xvalue end return hash end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
it "inserts the documents" do session.should_receive(:execute).with do |insert| insert.documents.should eq [{a: 1}, {b: 2}] end collection.insert([{a: 1}, {b: 2}]) end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
it "does not set the slave ok flag" do stats = Support::Stats.collect do session.with(consistency: :strong)[:users].find(scope: scope).one end query = stats[:primary].grep(Moped::Protocol::Query).first query.flags.should_not include :slave_ok end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def allowed_for_superuser(session) $logger.debug( "permission check superuser username=#{session[:username]} groups=#{session[:groups]}" ) if SUPERUSER != session[:username] $logger.debug('permission denied') return false end $logger.debug('permission granted for superuser') return true end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def ajax_delete_mails Log.add_info(request, params.inspect) return unless request.post? folder_id = params[:id] mail_account_id = params[:mail_account_id] SqlHelper.validate_token([folder_id, mail_account_id]) unless params[:check_mail].blank? mail_folder = MailFolder.find(folder_id) trash_folder = MailFolder.get_for(@login_user, mail_account_id, MailFolder::XTYPE_TRASH) count = 0 params[:check_mail].each do |email_id, value| next if value != '1' begin email = Email.find(email_id) rescue => evar end next if email.nil? or (email.user_id != @login_user.id) if trash_folder.nil? \ or folder_id == trash_folder.id.to_s \ or mail_folder.get_parents(false).include?(trash_folder.id.to_s) email.destroy flash[:notice] ||= t('msg.delete_success') else begin email.update_attribute(:mail_folder_id, trash_folder.id) flash[:notice] ||= t('msg.moved_to_trash') rescue => evar Log.add_error(request, evar) email.destroy flash[:notice] ||= t('msg.delete_success') end end count += 1 end end get_mails end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def on_toys_moved Log.add_info(request, params.inspect) return unless request.post? unless @login_user.nil? begin toy = Toy.find(params[:id]) rescue toy = nil end unless toy.nil? attrs = ActionController::Parameters.new({x: params[:x], y: params[:y]}) toy.update_attributes(attrs.permit(Toy::PERMIT_BASE)) end end render(:text => '') end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def self.taxonomy_conditions org = Organization.expand(Organization.current) if SETTINGS[:organizations_enabled] loc = Location.expand(Location.current) if SETTINGS[:locations_enabled] conditions = {} conditions[:organization_id] = Array(org).map { |o| o.subtree_ids }.flatten.uniq if org.present? conditions[:location_id] = Array(loc).map { |l| l.subtree_ids }.flatten.uniq if loc.present? conditions end
0
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
vulnerable
it "returns the first matching document" do users.find(scope: scope).one.should eq documents.first end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def self.get_tmpl_subfolder(name) SqlHelper.validate_token([name]) tmpl_folder = Folder.where("folders.name='#{TMPL_ROOT}'").first unless tmpl_folder.nil? con = "(parent_id=#{tmpl_folder.id}) and (name='#{name}')" begin child = Folder.where(con).first rescue => evar Log.add_error(nil, evar) end end return [tmpl_folder, child] end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def show_tree Log.add_info(request, params.inspect) if !@login_user.nil? and @login_user.admin?(User::AUTH_FOLDER) @group_id = nil if !params[:thetisBoxSelKeeper].nil? @group_id = params[:thetisBoxSelKeeper].split(':').last elsif !params[:group_id].nil? and !params[:group_id].empty? @group_id = params[:group_id] end @folder_tree = Folder.get_tree_by_group_for_admin(@group_id || '0') else @folder_tree = Folder.get_tree_for(@login_user) end end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
it "should raise a warning (and keep parsing) on having an incorrectly formatted header" do STDERR.should_receive(:puts).with("WARNING: Could not parse (and so ignoring) 'quite Delivered-To: [email protected]'") Mail.read(fixture('emails', 'plain_emails', 'raw_email_incorrect_header.eml')).to_s end
1
Ruby
CWE-93
Improper Neutralization of CRLF Sequences ('CRLF Injection')
The software uses CRLF (carriage return line feeds) as a special element, e.g. to separate lines or records, but it does not neutralize or incorrectly neutralizes CRLF sequences from inputs.
https://cwe.mitre.org/data/definitions/93.html
safe
it "should not do anything when state neither Expanded nor Collapsed" do comment = double(Comment) Comment.should_not_receive(:find).with("1") xhr :get, :timeline, :type => "comment", :id => "1", :state => "Explode" end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it "drops all indexes for the collection" do indexes[name: 1].should be_nil indexes[age: -1].should be_nil end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def initialize(seeds, options = {}) @cluster = Cluster.new(seeds) @options = options @options[:consistency] ||= :eventual end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def initialize_copy(_) @nodes = @nodes.map &:dup end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def remove_application(users) return if users.nil? or users.empty? array = ["(xtype='#{Comment::XTYPE_APPLY}')"] array << "(item_id=#{self.item_id})" user_con_a = [] users.each do |user_id| user_con_a << "(user_id=#{user_id})" end array << '(' + user_con_a.join(' or ') + ')' Comment.destroy_all(array.join(' and ')) end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def ajax_exclude_users Log.add_info(request, params.inspect) return unless request.post? group_id = params[:id] SqlHelper.validate_token([group_id]) unless params[:check_user].blank? count = 0 params[:check_user].each do |user_id, value| if value == '1' begin user = User.find(user_id) user.exclude_from(group_id) user.save! rescue => evar user = nil Log.add_error(request, evar) end count += 1 end end flash[:notice] = t('msg.update_success') end get_users end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it "closes open cursors" do users.insert(100.times.map { Hash["scope" => scope] }) stats = Support::Stats.collect do users.find(scope: scope).limit(5).entries end stats[node_for_reads].grep(Moped::Protocol::KillCursors).count.should eq 1 end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def update if params[:user] roles = params[:user].delete("spree_role_ids") end if @user.update_attributes(params[:user]) if roles @user.spree_roles = roles.reject(&:blank?).collect{|r| Spree::Role.find(r)} end if params[:user][:password].present? # this logic needed b/c devise wants to log us out after password changes user = Spree::User.reset_password_by_token(params[:user]) sign_in(@user, :event => :authentication, :bypass => !Spree::Auth::Config[:signout_after_password_change]) end flash.now[:notice] = t(:account_updated) render :edit else render :edit end end
1
Ruby
CWE-264
Permissions, Privileges, and Access Controls
Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.
https://cwe.mitre.org/data/definitions/264.html
safe
def self.on_desktop?(user, xtype, target_id) return false if user.nil? or xtype.nil? or target_id.nil? SqlHelper.validate_token([xtype, target_id]) con = "(user_id=#{user.id}) and (xtype='#{xtype}') and (target_id=#{target_id.to_i})" begin toy = Toy.where(con).first rescue => evar Log.add_error(nil, evar) end return (!toy.nil?) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it "creates an index with no options" do indexes.create name: 1 indexes[name: 1].should_not be_nil end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def self.save_sync_new_tokens(config, new_tokens, nodes, cluster_name) with_new_tokens = PCSTokens.new(config.text) with_new_tokens.tokens.update(new_tokens) config_new = PcsdTokens.from_text(with_new_tokens.text) if not cluster_name or cluster_name.empty? # we run on a standalone host, no config syncing config_new.version += 1 config_new.save() return true, {} end # we run in a cluster so we need to sync the config publisher = ConfigPublisher.new( PCSAuth.getSuperuserSession(), [config_new], nodes, cluster_name, new_tokens ) old_configs, node_responses = publisher.publish() if not old_configs.include?(config_new.class.name) # no node had newer tokens file, we are ok, everything done return true, node_responses end # get tokens from all nodes and merge them fetcher = ConfigFetcher.new( PCSAuth.getSuperuserSession(), [config_new.class], nodes, cluster_name ) fetched_tokens = fetcher.fetch_all()[config_new.class.name] config_new = Cfgsync::merge_tokens_files(config, fetched_tokens, new_tokens) # and try to publish again return Cfgsync::save_sync_new_version( config_new, nodes, cluster_name, true, new_tokens ) end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def quote_column_name(name) #:nodoc: @quoted_column_names[name] ||= "`#{name}`" end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def resource_change_group(params, request, session) if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end if params[:resource_id].nil? or params[:group_id].nil? return [400, 'resource_id and group_id have to be specified.'] end if params[:group_id].empty? if params[:old_group_id] _, stderr, retval = run_cmd( session, PCS, 'resource', 'group', 'remove', params[:old_group_id], params[:resource_id] ) if retval != 0 return [400, "Unable to remove resource '#{params[:resource_id]}' " + "from group '#{params[:old_group_id]}': #{stderr.join('')}" ] end end return 200 end _, stderr, retval = run_cmd( session, PCS, 'resource', 'group', 'add', params[:group_id], params[:resource_id] ) if retval != 0 return [400, "Unable to add resource '#{params[:resource_id]}' to " + "group '#{params[:group_id]}': #{stderr.join('')}" ] end return 200 end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
it "raises a QueryFailure exception" do expect { session.query(query) }.to raise_exception(Moped::Errors::QueryFailure) end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def self.get_team_folder(team_id) SqlHelper.validate_token([team_id]) begin return Folder.where("(owner_id=#{team_id}) and (xtype='#{Folder::XTYPE_TEAM}')").first rescue => evar Log.add_error(nil, evar) return nil end end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def wf_issue Log.add_info(request, params.inspect) return unless request.post? begin @item = Item.find(params[:id]) @workflow = @item.workflow rescue => evar Log.add_error(request, evar) end attrs = ActionController::Parameters.new({status: Workflow::STATUS_ACTIVE, issued_at: Time.now}) @workflow.update_attributes(attrs.permit(Workflow::PERMIT_BASE)) @orders = @workflow.get_orders render(:partial => 'ajax_workflow', :layout => false) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def destroy Log.add_info(request, params.inspect) return unless request.post? begin OfficialTitle.destroy(params[:id]) rescue => evar Log.add_error(nil, evar) end @group_id = params[:group_id] SqlHelper.validate_token([@group_id]) if @group_id.blank? @group_id = '0' # '0' for ROOT end render(:partial => 'groups/ajax_group_official_titles', :layout => false) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def self.extract_events(post) cooked = PrettyText.cook(post.raw, topic_id: post.topic_id, user_id: post.user_id) valid_options = VALID_OPTIONS.map { |o| "data-#{o}" } valid_custom_fields = [] SiteSetting.discourse_post_event_allowed_custom_fields.split('|').each do |setting| valid_custom_fields << { original: "data-#{setting}", normalized: "data-#{setting.gsub(/_/, '-')}" } end Nokogiri::HTML(cooked).css('div.discourse-post-event').map do |doc| event = nil doc.attributes.values.each do |attribute| name = attribute.name value = attribute.value if value && valid_options.include?(name) event ||= {} event[name.sub('data-', '').to_sym] = CGI.escapeHTML(value) end valid_custom_fields.each do |valid_custom_field| if value && valid_custom_field[:normalized] == name event ||= {} event[valid_custom_field[:original].sub('data-', '').to_sym] = CGI.escapeHTML(value) end end end event end.compact end
0
Ruby
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
it "sorts the results" do users.insert(documents) users.find(scope: scope).sort(n: -1).to_a.should eq documents.reverse end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
it "returns the socket" do cluster.stub(:sync) { cluster.servers << server } cluster.socket_for(:write).should eq socket end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def verify_signature(jwt) head = token_head(jwt) # Make sure the algorithm is supported and get the decode key. if head[:alg] == 'RS256' [rs256_decode_key(head[:kid]), head[:alg]] elsif head[:alg] == 'HS256' [@client_secret, head[:alg]] else raise OmniAuth::Auth0::TokenValidationError.new("Signature algorithm of #{head[:alg]} is not supported. Expected the ID token to be signed with RS256 or HS256") end end
0
Ruby
CWE-347
Improper Verification of Cryptographic Signature
The software does not verify, or incorrectly verifies, the cryptographic signature for data.
https://cwe.mitre.org/data/definitions/347.html
vulnerable