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 primary? @primary 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 closed? !@server || @server.closed? 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 bbs Log.add_info(request, params.inspect) if !params[:select_sorting].nil? sort_a = params[:select_sorting].split(' ') params[:sort_col] = sort_a.first params[:sort_type] = sort_a.last end list render(:action => 'bbs') 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 a new session" do session.with(new_options).should_not eql session 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 delete_attachment Log.add_info(request, params.inspect) return unless request.post? begin attach = Attachment.find(params[:attachment_id]) @item = Item.find(attach.item_id) unless @item.check_user_auth(@login_user, 'w', true) raise t('msg.need_to_be_owner') end attach.destroy @item.update_attribute(:updated_at, Time.now) rescue => evar Log.add_error(request, evar) end render(:partial => 'ajax_item_attachment', :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 test_jail_instances_should_have_limited_methods expected = ["class", "inspect", "method_missing", "methods", "respond_to?", "respond_to_missing?", "to_jail", "to_s", "instance_variable_get"] expected.delete('respond_to_missing?') if RUBY_VERSION > '1.9.3' # respond_to_missing? is private in rubies above 1.9.3 objects.each do |object| assert_equal expected.sort, reject_pretty_methods(object.to_jail.methods.map(&:to_s).sort) end 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 default_ids_hash(populate_values = false) ids = HashWithIndifferentAccess.new hash_keys.each do |col| ids[col] = populate_values ? Array(self.send(col)) : [] end ids 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 kill_cursors(*args) raise NotImplementedError, "#kill_cursors cannot be called on Context; it must be called directly on a node" 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_value(user_id, category, key) SqlHelper.validate_token([user_id, category, key]) con = [] con << "(user_id=#{user_id})" con << "(category='#{category}')" con << "(xkey='#{key}')" setting = Setting.where(con.join(' and ')).first return setting.xvalue unless setting.nil? return 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
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.realpath destination if File.respond_to? :realpath destination = File.expand_path destination raise Gem::Package::PathError.new(destination, destination_dir) unless destination.start_with? destination_dir + '/' destination.untaint destination end
1
Ruby
CWE-59
Improper Link Resolution Before File Access ('Link Following')
The software attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.
https://cwe.mitre.org/data/definitions/59.html
safe
def check_owner return if params[:id].blank? or @login_user.nil? begin owner_id = Workflow.find(params[:id]).user_id rescue owner_id = -1 end if !@login_user.admin?(User::AUTH_WORKFLOW) and owner_id != @login_user.id Log.add_check(request, '[check_owner]'+request.to_s) flash[:notice] = t('msg.need_to_be_owner') redirect_to(:controller => 'desktop', :action => 'show') 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 initialize(database, command) super database, :$cmd, command, limit: -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 receive_replies(operations) operations.map do |operation| read if operation.is_a?(Protocol::Query) || operation.is_a?(Protocol::GetMore) end 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 get_mail_content Log.add_info(request, params.inspect) email_id = params[:id] begin @email = Email.find(email_id) render(:partial => 'ajax_mail_content', :layout => false) rescue => evar Log.add_error(nil, evar) render(:text => '') 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 drop_on_desktop Log.add_info(request, params.inspect) return unless request.post? if @login_user.nil? t = Time.now render(:text => (t.hour.to_s + t.min.to_s + t.sec.to_s)) return end toy = Toy.new toy.user_id = @login_user.id toy.x = params[:x].to_i toy.y = params[:y].to_i toy.xtype, toy.target_id = params[:id].split(':') toy.save! render(:text => toy.id.to_s) 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 "with params as nil" do cl = subject.build_command_line("true", nil) expect(cl).to eq "true" 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
def paidhld_update Log.add_info(request, params.inspect) return unless request.post? year = params[:year].to_i num = params[:num].to_f user = User.find(params[:user_id]) unless user.nil? PaidHoliday.update_for(user.id, year, num) end flash[:notice] = t('msg.update_success') paidhld_list rescue => evar Log.add_error(request, evar) paidhld_list 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 "with params as nil" do cl = subject.build("true", nil) expect(cl).to eq "true" end
1
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
safe
def remote_remove_node(params, request, session) if not allowed_for_local_cluster(session, Permissions::FULL) return 403, 'Permission denied' end if params[:remove_nodename] != nil retval, output = remove_node(session, params[:remove_nodename]) else return 400, "No nodename specified" end if retval == 0 return JSON.generate([retval, get_corosync_conf()]) end return JSON.generate([retval,output]) 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 initialize @counter = 0 @machine_id = Digest::MD5.digest(Socket.gethostname).unpack("N")[0] @mutex = Mutex.new 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 stop Log.add_info(request, params.inspect) return unless request.post? ApplicationHelper.delete_file_safe(Research.get_pages) render(:text => '') rescue => evar Log.add_error(request, evar) render(:text => evar.to_s) 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 "changes the fields returned" do users.insert(documents) users.find(scope: scope).select(_id: 0).to_a.should eq documents 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 proxy(client, mongo) incoming_message = client.read(16) length, op_code = incoming_message.unpack("l<x8l<") incoming_message << client.read(length - 16) if op_code == OP_QUERY && ismaster_command?(incoming_message) # Intercept the ismaster command and send our own reply. client.write status_reply else # This is a normal command, so proxy it to the real mongo instance. mongo.write incoming_message if op_code == OP_QUERY || op_code == OP_GETMORE outgoing_message = mongo.read(4) length, = outgoing_message.unpack('l<') outgoing_message << mongo.read(length - 4) client.write outgoing_message end end 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 query Log.add_info(request, '') # Not to show passwords. unless @login_user.admin?(User::AUTH_ZEPTAIR) render(:text => 'ERROR:' + t('msg.need_to_be_admin')) return end target_user = nil SqlHelper.validate_token([params[:user_id], params[:zeptair_id], params[:group_id]]) unless params[:user_id].blank? target_user = User.find(params[:user_id]) end unless params[:zeptair_id].blank? zeptair_id = params[:zeptair_id] target_user = User.where("zeptair_id=#{zeptair_id}").first end if target_user.nil? if params[:group_id].blank? sql = 'select distinct Item.* from items Item, attachments Attachment' sql << " where Item.xtype='#{Item::XTYPE_ZEPTAIR_POST}' and Item.id=Attachment.item_id" sql << ' order by Item.user_id ASC' else group_ids = [params[:group_id]] if params[:recursive] == 'true' group_ids += Group.get_childs(params[:group_id], true, false) end groups_con = [] group_ids.each do |group_id| groups_con << SqlHelper.get_sql_like(['User.groups'], "|#{@group_id}|") end sql = 'select distinct Item.* from items Item, attachments Attachment, users User' sql << " where Item.xtype='#{Item::XTYPE_ZEPTAIR_POST}' and Item.id=Attachment.item_id" sql << " and (Item.user_id=User.id and (#{groups_con.join(' or ')}))" sql << ' order by Item.user_id ASC' end @post_items = Item.find_by_sql(sql) else @post_item = ZeptairPostHelper.get_item_for(target_user) end rescue => evar Log.add_error(request, evar) render(:text => 'ERROR:' + t('msg.system_error')) 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 "creates an index with no options" do indexes.create name: 1 indexes[name: 1].should_not be_nil 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 primary? @primary 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 login(username, password) session.context.login(name, username, password) 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 destroy Log.add_info(request, params.inspect) return unless request.post? if params[:check_equipment].nil? list render(:action => 'list') return end count = 0 params[:check_equipment].each do |equipment_id, value| SqlHelper.validate_token([equipment_id]) if value == '1' Equipment.delete(equipment_id) count += 1 end end flash[:notice] = count.to_s + t('equipment.deleted') list render(:action => 'list') 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 Log.add_info(request, '') # Not to show passwords. unless @login_user.admin?(User::AUTH_ZEPTAIR) render(:text => 'ERROR:' + t('msg.need_to_be_admin')) return end target_user = nil user_id = params[:user_id] zeptair_id = params[:zeptair_id] group_id = params[:group_id] SqlHelper.validate_token([user_id, zeptair_id, group_id]) unless user_id.blank? target_user = User.find(user_id) end unless zeptair_id.blank? target_user = User.where("zeptair_id=#{zeptair_id.to_i}").first end if target_user.nil? if group_id.blank? sql = 'select distinct Item.* from items Item, attachments Attachment' sql << " where Item.xtype='#{Item::XTYPE_ZEPTAIR_POST}' and Item.id=Attachment.item_id" sql << ' order by Item.user_id ASC' else group_ids = [group_id] if params[:recursive] == 'true' group_ids += Group.get_childs(group_id, true, false) end groups_con = [] group_ids.each do |grp_id| groups_con << SqlHelper.get_sql_like(['User.groups'], "|#{grp_id}|") end sql = 'select distinct Item.* from items Item, attachments Attachment, users User' sql << " where Item.xtype='#{Item::XTYPE_ZEPTAIR_POST}' and Item.id=Attachment.item_id" sql << " and (Item.user_id=User.id and (#{groups_con.join(' or ')}))" sql << ' order by Item.user_id ASC' end @post_items = Item.find_by_sql(sql) else @post_item = ZeptairPostHelper.get_item_for(target_user) end 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 initialize(address) @address = address host, port = address.split(":") @ip_address = ::Socket.getaddrinfo(host, nil, ::Socket::AF_INET, ::Socket::SOCK_STREAM).first[3] @port = port.to_i @resolved_address = "#{@ip_address}:#{@port}" @timeout = 5 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 "with params as empty Hash" do cl = subject.build("true", {}) expect(cl).to eq "true" end
1
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
safe
it 'does not log in with incorrect two factor' do post "/session/email-login/#{email_token.token}", params: { second_factor_token: "0000", second_factor_method: UserSecondFactor.methods[:totp] } expect(response.status).to eq(200) expect(CGI.unescapeHTML(response.body)).to include(I18n.t( "login.invalid_second_factor_code" )) 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 nofollowify_links(string) if this_blog.dofollowify string else string.gsub(/<a(.*?)>/i, '<a\1 rel="nofollow">') end 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 "connects and yields the secondary node" do Time.stub(:new).and_return(Time.now + 10) replica_set.with_secondary do |node| node.command "admin", ping: 1 @secondaries.map(&:address).should include node.address 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
it "passes the initial directory" do expect(File.cleanpath('C/../../D')).to eq "../D" 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 destroy_profile_sheet Log.add_info(request, params.inspect) return unless request.post? user_id = params[:id] @user = User.find(user_id) item_id = @user.item_id @user.update_attribute(:item_id, nil) Item.find(item_id).destroy @item = nil render(:partial => 'ajax_profile_sheet', :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 get_map Log.add_info(request, params.inspect) @group_id = (params[:id] || '0') # '0' for ROOT SqlHelper.validate_token([@group_id]) @office_map = OfficeMap.get_for_group(@group_id) session[:group_id] = params[:id] session[:group_option] = 'office_map' render(:partial => 'ajax_map', :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 entries(path=nil, identifier=nil, options={}) p1 = scm_iconv(@path_encoding, 'UTF-8', path) manifest = hg('rhmanifest', '-r', CGI.escape(hgrev(identifier)), '--', CGI.escape(without_leading_slash(p1.to_s))) do |io| output = io.read.force_encoding('UTF-8') begin parse_xml(output)['rhmanifest']['repository']['manifest'] rescue end end path_prefix = path.blank? ? '' : with_trailling_slash(path) entries = Entries.new as_ary(manifest['dir']).each do |e| n = scm_iconv('UTF-8', @path_encoding, CGI.unescape(e['name'])) p = "#{path_prefix}#{n}" entries << Entry.new(:name => n, :path => p, :kind => 'dir') end as_ary(manifest['file']).each do |e| n = scm_iconv('UTF-8', @path_encoding, CGI.unescape(e['name'])) p = "#{path_prefix}#{n}" lr = Revision.new(:revision => e['revision'], :scmid => e['node'], :identifier => e['node'], :time => Time.at(e['time'].to_i)) entries << Entry.new(:name => n, :path => p, :kind => 'file', :size => e['size'].to_i, :lastrev => lr) end entries rescue HgCommandAborted nil # means not found end
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
it "should redeem the invite if invited by non staff and approve if staff not required to approve" do inviter = invite.invited_by user = invite_redeemer.redeem expect(user.name).to eq(name) expect(user.username).to eq(username) expect(user.invited_by).to eq(inviter) expect(inviter.notifications.count).to eq(1) expect(user.approved).to eq(true) 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 distinct values for +key+" do users.insert(documents) users.find(scope: scope).distinct(:count).should =~ [0, 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 self.get_value(user_id, category, key) SqlHelper.validate_token([user_id, category, key]) con = [] con << "(user_id=#{user_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 protected! gui_request = ( # these are URLs for web pages request.path == '/' or request.path == '/manage' or request.path == '/permissions' or request.path.match('/managec/.+/main') ) if request.path.start_with?('/remote/') or request.path == '/run_pcs' unless PCSAuth.loginByToken(session, cookies) halt [401, '{"notauthorized":"true"}'] end else #/managec/* /manage/* /permissions if !gui_request and request.env['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest' then # Accept non GUI requests only with header # "X_REQUESTED_WITH: XMLHttpRequest". (check if they are send via AJAX). # This prevents CSRF attack. halt [401, '{"notauthorized":"true"}'] elsif not PCSAuth.isLoggedIn(session) if gui_request session[:pre_login_path] = request.path redirect '/login' else halt [401, '{"notauthorized":"true"}'] end end 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
it "should find a user by first name or last name" do @cur_user.stub(:pref).and_return(:activity_user => 'Billy') controller.instance_variable_set(:@current_user, @cur_user) User.should_receive(:where).with(:first_name => 'Billy').and_return([@user]) User.should_receive(:where).with(:last_name => 'Billy').and_return([@user]) controller.send(:activity_user).should == 1 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.get_childs(folder_id, conditions, recursive, admin, ret_obj) SqlHelper.validate_token([folder_id]) arr = [] if recursive folder_tree = Folder.get_tree(Hash.new, conditions, folder_id, admin) return [] if folder_tree.nil? folder_tree.each do |parent_id, childs| if ret_obj arr |= childs else childs.each do |folder| folder_id = folder.id.to_s arr << folder_id unless arr.include?(folder_id) end end end else con = Marshal.load(Marshal.dump(conditions)) if con.nil? con = '' else con << ' and ' end con << "parent_id=#{folder_id}" unless admin con << " and (xtype is null or not (xtype='#{Folder::XTYPE_SYSTEM}'))" end folders = Folder.where(con).order('xorder ASC').to_a if ret_obj arr = folders else folders.each do |folder| arr << folder.id.to_s end end end return arr 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 remove_constraint_rule_remote(params, request, session) if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end if params[:rule_id] retval = remove_constraint_rule(session, params[:rule_id]) if retval == 0 return "Constraint rule #{params[:rule_id]} removed" else return [400, "Error removing constraint rule: #{params[:rule_id]}"] end else return [400, "Bad Constraint Rule Options"] 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 remove_all_groups check_write_access! self.package_group_role_relationships.delete_all 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 "should reject a subjectAltName for a non-DNS value" do @request.stubs(:subject_alt_names).returns ['DNS:foo', 'email:[email protected]'] expect { @ca.sign(@name, true) }.to raise_error( Puppet::SSL::CertificateAuthority::CertificateSigningError, /subjectAltName outside the DNS label space/ ) 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 xml" do expect(user.to_xml).to eql([user.name].to_xml) 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 get_items if params[:action] == 'get_items' Log.add_info(request, params.inspect) end @folder_id = params[:id] SqlHelper.validate_token([@folder_id]) if Folder.check_user_auth(@folder_id, @login_user, 'r', true) =begin # if !@login_user.nil? and @login_user.admin?(User::AUTH_ITEM) # @items = Folder.get_items_admin(@folder_id) # else # @items = Folder.get_items(@login_user, @folder_id) # end =end # FEATURE_PAGING_IN_TREE >>> @sort_col = params[:sort_col] @sort_type = params[:sort_type] if @sort_col.blank? or @sort_type.blank? @sort_col, @sort_type = FoldersHelper.get_sort_params(@folder_id) end SqlHelper.validate_token([@sort_col, @sort_type]) folder_ids = nil add_con = nil if @folder_id.nil? and params[:find_in] != Item::FOLDER_ALL add_con = "(Item.folder_id != 0) and (Folder.disp_ctrl like '%|#{Folder::DISPCTRL_BBS_TOP}|%')" else case params[:find_in] when Item::FOLDER_ALL ; when Item::FOLDER_CURRENT folder_ids = [@folder_id] when Item::FOLDER_LOWER folder_ids = Folder.get_childs(@folder_id, nil, true, false, false) folder_ids.unshift(@folder_id) else folder_ids = [@folder_id] end unless folder_ids.nil? delete_ary = [] folder_ids.each do |folder_id| unless Folder.check_user_auth(folder_id, @login_user, 'r', true) delete_ary << folder_id end end folder_ids -= delete_ary unless delete_ary.empty? end end sql = ItemsHelper.get_list_sql(@login_user, params[:keyword], folder_ids, @sort_col, @sort_type, 0, false, add_con) @item_pages, @items, @total_num = paginate_by_sql(Item, sql, 10) # FEATURE_PAGING_IN_TREE <<< else @items = [] flash[:notice] = 'ERROR:' + t('folder.need_auth_to_read') 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 Item.destroy(params[:id]) rescue => evar Log.add_error(request, evar) end if params[:from_action].nil? render(:text => params[:id]) else params.delete(:controller) params.delete(:action) params.delete(:id) flash[:notice] = t('msg.delete_success') params[:action] = params[:from_action] redirect_to(params) 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 get_cluster_tokens(params, request, session) # pcsd runs as root thus always returns hacluster's tokens if not allowed_for_local_cluster(session, Permissions::FULL) return 403, "Permission denied" end on, off = get_nodes nodes = on + off nodes.uniq! return [200, JSON.generate(get_tokens_of_nodes(nodes))] 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 execute(op) mode = options[:consistency] == :eventual ? :read : :write socket = socket_for(mode) if safe? last_error = Protocol::Command.new( "admin", { getlasterror: 1 }.merge(safety) ) socket.execute(op, last_error).documents.first.tap do |result| raise Errors::OperationFailure.new( op, result ) if result["err"] || result["errmsg"] end else socket.execute(op) 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 query(database, collection, selector, options = {}) if consistency == :eventual options[:flags] ||= [] options[:flags] |= [:slave_ok] end with_node do |node| node.query(database, collection, selector, options) 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
it "should choose :file_server when the settings name is 'puppet' and no server is specified" do modules = mock 'modules' @request.expects(:protocol).returns "puppet" @request.expects(:server).returns nil Puppet.settings.expects(:value).with(:name).returns "puppet" @object.select_terminus(@request).should == :file_server 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 self.get_group_value(group_id, category, key) SqlHelper.validate_token([group_id, category, key]) con = [] con << "(group_id=#{group_id.to_i})" con << "(category='#{category}')" con << "(xkey='#{key}')" setting = Setting.where(con.join(' and ')).first return setting.xvalue unless setting.nil? return 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 a hostgroup with a parent parameter" do post :create, {"hostgroup" => {"name"=>"test_it", "parent_id" => @base.id, :realm_id => realms(:myrealm).id, :group_parameters_attributes => {"0" => {:name => "x", :value =>"overridden", :_destroy => ""}}}}, set_session_user assert_redirected_to hostgroups_url hostgroup = Hostgroup.unscoped.where(:name => "test_it").last as_admin do assert_equal "overridden", hostgroup.parameters["x"] 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
it "removes the socket" do cluster.should_receive(:remove).with(dead_server) cluster.socket_for :write 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 remove_all session.with(consistency: :strong) do |session| session.context.remove operation.database, operation.collection, operation.selector 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
it "returns the result of the block" do session.with(new_options) { false }.should eq false 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 "delegates to the cluster" do session.cluster.should_receive(:socket_for).with(:read) session.send(:socket_for, :read) 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 start @nodes.each &:start @worker = Thread.start do Thread.abort_on_exception = true catch(:shutdown) do loop do Moped.logger.debug "replica_set: waiting for next client" server, client = @manager.next_client if server Moped.logger.debug "replica_set: proxying incoming request to mongo" server.proxy(client, @mongo) else Moped.logger.debug "replica_set: no requests; passing" Thread.pass end end end end 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 do_project_copy( params ) # copy entire project in the backend begin path = "/source/#{URI.escape(self.name)}" path << Suse::Backend.build_query_from_hash(params, [:cmd, :user, :comment, :oproject, :withbinaries, :withhistory, :makeolder]) Suse::Backend.post path, nil rescue Suse::Backend::HTTPError => e logger.debug "copy failed: #{e.message}" # we need to check results of backend in any case (also timeout error eg) end # set user if nil, needed for delayed job in Package model User.current ||= User.find_by_login(params[:user]) # restore all package meta data objects in DB backend_pkgs = Collection.find :package, :match => "@project='#{self.name}'" backend_pkgs.each_package do |package| path = "/source/#{URI.escape(self.name)}/#{package.name}/_meta" p = self.packages.new(name: package.name) p.update_from_xml(Xmlhash.parse(Suse::Backend.get(path).body)) p.save! # do not store end packages.each { |p| p.sources_changed } end
0
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
vulnerable
def begin(name) stack(name).push true 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 delete_break Log.add_info(request, params.inspect) return unless request.post? @timecard = Timecard.find(params[:id]) if params[:org_start].nil? org_start = nil else org_start = UtilDateTime.parse(params[:org_start]).to_time end @timecard.delete_break(org_start) unless params[:user_id].nil? @selected_user = User.find(params[:user_id]) if @selected_user.id != @login_user.id and !@login_user.admin?(User::AUTH_TIMECARD) Log.add_check(request, '[User::AUTH_TIMECARD]'+request.to_s) redirect_to(:controller => 'frames', :action => 'http_error', :id => '401') return end end render(:partial => 'ajax_update_break', :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 initialize(session, configs, nodes, cluster_name, tokens={}) @configs = configs @nodes = nodes @cluster_name = cluster_name @published_configs_names = @configs.collect { |cfg| cfg.class.name } @additional_tokens = tokens @session = session 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 group Log.add_info(request, params.inspect) date_s = params[:date] if date_s.nil? or date_s.empty? @date = Date.today date_s = @date.strftime(Schedule::SYS_DATE_FORM) else @date = Date.parse date_s end if params[:display] == 'mine' redirect_to(:action => 'month') else display_type = params[:display].split('_').first display_id = params[:display].split('_').last @selected_users = Group.get_users(display_id) @group_id = display_id if !@login_user.get_groups_a.include?(@group_id.to_s) and !@login_user.admin?(User::AUTH_TIMECARD) Log.add_check(request, '[User.get_groups_a.include?]'+request.to_s) redirect_to(:controller => 'frames', :action => 'http_error', :id => '401') return end 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 "recognizes and generates #index" do { :get => "/users" }.should route_to(:controller => "users", :action => "index") 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 create_patchinfo_from_request(req) check_write_access! patchinfo = Package.new(:name => "patchinfo", :title => "Patchinfo", :description => "Collected packages for update") self.packages << patchinfo patchinfo.add_flag("build", "enable", nil, nil) patchinfo.add_flag("useforbuild", "disable", nil, nil) patchinfo.add_flag("publish", "enable", nil, nil) unless self.flags.find_by_flag_and_status("access", "disable") patchinfo.store # create patchinfo XML file node = Nokogiri::XML::Builder.new attrs = { } if self.project_type.to_s == "maintenance_incident" # this is a maintenance incident project, the sub project name is the maintenance ID attrs[:incident] = self.name.gsub(/.*:/, '') end description = req.description || '' node.patchinfo(attrs) do |n| n.packager req.creator n.category "recommended" # update_patchinfo may switch to security n.rating "low" n.summary description.split(/\n|\r\n/)[0] # first line only n.description req.description end data = ActiveXML::Node.new( node.doc.to_xml ) data = self.update_patchinfo( data, enfore_issue_update: true ) p = { :user => User.current.login, :comment => "generated by request id #{req.id} accept call" } patchinfo_path = "/source/#{CGI.escape(patchinfo.project.name)}/patchinfo/_patchinfo" patchinfo_path << Suse::Backend.build_query_from_hash(p, [:user, :comment]) Suse::Backend.put( patchinfo_path, data.dump_xml ) patchinfo.sources_changed 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
def instantiate variant, mac=nil # Filenames must end in a hex representation of a mac address but only if mac is not empty log_halt 403, "Invalid MAC address: #{mac}" unless valid_mac?(mac) || mac.nil? log_halt 403, "Unrecognized pxeboot config type: #{variant}" unless defined? variant.capitalize eval "Proxy::TFTP::#{variant.capitalize}.new" end
0
Ruby
CWE-284
Improper Access Control
The software does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
https://cwe.mitre.org/data/definitions/284.html
vulnerable
def tok(s) case s[0] when ?{ then ['{', s[0,1], s[0,1]] when ?} then ['}', s[0,1], s[0,1]] when ?: then [':', s[0,1], s[0,1]] when ?, then [',', s[0,1], s[0,1]] when ?[ then ['[', s[0,1], s[0,1]] when ?] then [']', s[0,1], s[0,1]] when ?n then nulltok(s) when ?t then truetok(s) when ?f then falsetok(s) when ?" then strtok(s) when Spc, ?\t, ?\n, ?\r then [:space, s[0,1], s[0,1]] else numtok(s) end end def nulltok(s); s[0,4] == 'null' ? [:val, 'null', nil] : [] end def truetok(s); s[0,4] == 'true' ? [:val, 'true', true] : [] end def falsetok(s); s[0,5] == 'false' ? [:val, 'false', false] : [] end def numtok(s) m = /-?([1-9][0-9]+|[0-9])([.][0-9]+)?([eE][+-]?[0-9]+)?/.match(s) if m && m.begin(0) == 0 if !m[2] && !m[3] [:val, m[0], Integer(m[0])] elsif m[2] [:val, m[0], Float(m[0])] else # We don't convert scientific notation [:val, m[0], m[0]] end else [] end end def strtok(s) m = /"([^"\\]|\\["\/\\bfnrt]|\\u[0-9a-fA-F]{4})*"/.match(s) if ! m raise Error, "invalid string literal at #{abbrev(s)}" end [:str, m[0], unquote(m[0])] end
1
Ruby
CWE-399
Resource Management Errors
Weaknesses in this category are related to improper management of system resources.
https://cwe.mitre.org/data/definitions/399.html
safe
def gate_process HistoryHelper.keep_last(request) @login_user = User.find_by_id(session[:login_user_id]) begin if @login_user.nil? \ or @login_user.time_zone.nil? or @login_user.time_zone.empty? unless THETIS_USER_TIMEZONE_DEFAULT.nil? or THETIS_USER_TIMEZONE_DEFAULT.empty? Time.zone = THETIS_USER_TIMEZONE_DEFAULT end else Time.zone = @login_user.time_zone end rescue => evar logger.fatal(evar.to_s) 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 restart stop start 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 file_list io # :nodoc: header = String.new read_until_dashes io do |line| header << line end YAML.load header 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
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-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_images_order Log.add_info(request, params.inspect) order_ary = params[:images_order] item = Item.find(params[:id]) item.images_without_content.each do |img| class << img def record_timestamps; false; end end img.update_attribute(:xorder, order_ary.index(img.id.to_s) + 1) class << img remove_method :record_timestamps end end render(:text => '') rescue => evar Log.add_error(request, evar) render(:text => evar.to_s) 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 value from the block" do session.with { :value }.should eq :value 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 redirect_back_or_default(default, options={}) back_url = params[:back_url].to_s if back_url.present? begin uri = URI.parse(back_url) # do not redirect user to another host or to the login or register page if ((uri.relative? && back_url.match(%r{\A/\w})) || (uri.host == request.host)) && !uri.path.match(%r{/(login|account/register)}) redirect_to(back_url) return end rescue URI::InvalidURIError logger.warn("Could not redirect to invalid URL #{back_url}") # redirect to default end elsif options[:referer] redirect_to_referer_or default return end redirect_to default false 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_group_value(group_id, category, key, value) SqlHelper.validate_token([group_id, category, key]) con = [] con << "(group_id=#{group_id.to_i})" con << "(category='#{category}')" con << "(xkey='#{key}')" setting = Setting.where(con.join(' and ')).first if value.nil? unless setting.nil? setting.destroy end else if setting.nil? setting = Setting.new setting.group_id = group_id setting.category = category setting.xkey = key setting.xvalue = value setting.save! else setting.update_attribute(:xvalue, value) end 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 'returns the right response' do get "/session/email-login/adasdad" expect(response.status).to eq(200) expect(CGI.unescapeHTML(response.body)).to match( I18n.t('email_login.invalid_token') ) 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 update_map Log.add_info(request, params.inspect) group_id = params[:group_id] SqlHelper.validate_token([group_id]) @office_map = OfficeMap.get_for_group(group_id, true) params[:office_map].delete(:group_id) @office_map.update_attributes(params.require(:office_map).permit(OfficeMap::PERMIT_BASE)) params.delete(:office_map) flash[:notice] = t('msg.update_success') render(:partial => 'groups/ajax_group_map', :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 "inserts a single document" do document = { "_id" => Moped::BSON::ObjectId.new, "scope" => scope } session[:users].insert(document) session[:users].find(document).one.should eq document 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 test_update_valid Realm.any_instance.stubs(:valid?).returns(true) put :update, {:id => Realm.first.name, :realm => { :realm_proxy_id => SmartProxy.first.id } }, set_session_user assert_equal SmartProxy.first.id, Realm.first.realm_proxy_id assert_redirected_to realms_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
def login Log.add_info(request, '') # Not to show passwords. user = User.authenticate(params[:user]) if user.nil? flash[:notice] = '<span class=\'font_msg_bold\'>'+t('user.u_name')+'</span>'+t('msg.or')+'<span class=\'font_msg_bold\'>'+t('password.name')+'</span>'+t('msg.is_invalid') if params[:fwd_controller].blank? redirect_to(:controller => 'login', :action => 'index') else url_h = {:controller => 'login', :action => 'index', :fwd_controller => params[:fwd_controller], :fwd_action => params[:fwd_action]} unless params[:fwd_params].nil? params[:fwd_params].each do |key, val| url_h["fwd_params[#{key}]"] = val end end redirect_to(url_h) end else @login_user = LoginHelper.on_login(user, session) if params[:fwd_controller].blank? prms = ApplicationHelper.get_fwd_params(params) prms.delete('user') prms[:controller] = 'desktop' prms[:action] = 'show' redirect_to(prms) else url_h = {:controller => params[:fwd_controller], :action => params[:fwd_action]} url_h = url_h.update(params[:fwd_params]) unless params[:fwd_params].nil? redirect_to(url_h) end 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 each documents = load documents.each { |doc| yield doc } while more? return kill if limited? && @limit <= 0 documents = get_more documents.each { |doc| yield doc } end 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 show if params[:action] == 'show' Log.add_info(request, params.inspect) end @mail_filter = MailFilter.find_by_id(params[:id]) if @mail_filter.nil? render(:text => 'ERROR:' + t('msg.already_deleted', :name => MailFilter.model_name.human)) return else if @mail_filter.mail_account.user_id != @login_user.id render(:text => 'ERROR:' + t('msg.need_to_be_owner')) return end end render(:action => 'show', :layout => (!request.xhr?)) 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.set_statistics_groups(group_ids) yaml = Research.get_config_yaml yaml = Hash.new if yaml.nil? if group_ids.nil? unless yaml[:statistics].nil? yaml[:statistics].delete(:groups) end else if yaml[:statistics].nil? yaml[:statistics] = Hash.new end yaml[:statistics][:groups] = group_ids.join('|') end Research.save_config_yaml(yaml) return ary 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 insert(documents) documents = [documents] unless documents.is_a? Array database.session.with(consistency: :strong) do |session| session.context.insert(database.name, name, documents) end 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 valid?(user, password) return false if user.blank? if PasswordHash.legacy?(user.password, password) update_password(user, password) return true end PasswordHash.verified?(user.password, password) 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
def self.load input ::YAML.safe_load(input, [::Symbol]) end
1
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
safe
def update article = Ticket::Article.find(params[:id]) authorize!(article) clean_params = Ticket::Article.association_name_to_id_convert(params) clean_params = Ticket::Article.param_cleanup(clean_params, true) # only apply preferences changes (keep not updated keys/values) clean_params = article.param_preferences_merge(clean_params) article.update!(clean_params) if response_expand? result = article.attributes_with_association_names render json: result, status: :ok return end if response_full? full = Ticket::Article.full(params[:id]) render json: full, status: :ok return end render json: article.attributes_with_association_names, status: :ok 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 hg(*args, &block) # as of hg 4.4.1, early parsing of bool options is not terminated at '--' if args.any? { |s| s =~ HG_EARLY_BOOL_ARG } raise HgCommandArgumentError, "malicious command argument detected" end if args.take_while { |s| s != '--' }.any? { |s| s =~ HG_EARLY_LIST_ARG } raise HgCommandArgumentError, "malicious command argument detected" end repo_path = root_url || url full_args = ['-R', repo_path, '--encoding', 'utf-8'] full_args << '--config' << "extensions.redminehelper=#{HG_HELPER_EXT}" full_args << '--config' << 'diff.git=false' full_args += args ret = shellout( self.class.sq_bin + ' ' + full_args.map { |e| shell_quote e.to_s }.join(' '), &block ) if $? && $?.exitstatus != 0 raise HgCommandAborted, "hg exited with non-zero status: #{$?.exitstatus}" end ret end
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
it "rejects a file if named .html and is as HTML, but we're told JPG" do file = File.open(fixture_file("empty.html")) assert Paperclip::MediaTypeSpoofDetector.using(file, "empty.html", "image/jpg").spoofed? 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 generate(time, counter = 0) [time, @machine_id, Process.pid, counter << 8].pack("N NX lXX NX") 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.using(file, name, content_type) new(file, name, content_type) 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 get_mail_attachment Log.add_info(request, params.inspect) attached_id = params[:id].to_i begin mail_attach = MailAttachment.find(attached_id) rescue => evar end if mail_attach.nil? redirect_to(THETIS_RELATIVE_URL_ROOT + '/404.html') return end begin email = Email.find(mail_attach.email_id) rescue => evar end if email.nil? or email.user_id != @login_user.id render(:text => '') return end mail_attach_name = mail_attach.name agent = request.env['HTTP_USER_AGENT'] unless agent.nil? ie_ver = nil agent.scan(/\sMSIE\s?(\d+)[.](\d+)/){|m| ie_ver = m[0].to_i + (0.1 * m[1].to_i) } mail_attach_name = CGI::escape(mail_attach_name) unless ie_ver.nil? end filepath = mail_attach.get_path if FileTest.exist?(filepath) send_file(filepath, :filename => mail_attach_name, :stream => true, :disposition => 'attachment') else send_data('', :type => 'application/octet-stream;', :disposition => 'attachment;filename="'+mail_attach_name+'"') 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 "stores the database" do collection.database.should eq database 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 attachments_without_content return [] if self.id.nil? sql = 'select id, title, memo, name, size, content_type, comment_id, xorder, location from attachments' sql << ' where comment_id=' + self.id.to_s sql << ' order by xorder ASC' begin attachments = Attachment.find_by_sql(sql) rescue => evar Log.add_error(nil, evar) end return (attachments || []) 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 ajax_move_items Log.add_info(request, params.inspect) folder_id = params[:thetisBoxSelKeeper].split(':').last SqlHelper.validate_token([folder_id]) unless Folder.check_user_auth(folder_id, @login_user, 'w', true) flash[:notice] = 'ERROR:' + t('folder.need_auth_to_write_in') get_items return end unless params[:check_item].blank? is_admin = @login_user.admin?(User::AUTH_ITEM) count = 0 params[:check_item].each do |item_id, value| if value == '1' begin item = Item.find(item_id) next if !is_admin and item.user_id != @login_user.id item.update_attribute(:folder_id, folder_id) rescue => evar item = nil Log.add_error(request, evar) end count += 1 end end flash[:notice] = t('item.moved', :count => count) end get_items 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 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
it "re-enabled functionality if whitelisted" do Rack::MiniProfiler.config.authorization_mode = :whitelist expect(Rack::MiniProfiler).to receive(:request_authorized?) { true }.twice get '/html?pp=enable' last_response.body.should include('/mini-profiler-resources/includes.js') 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