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 remove_all delete = Protocol::Delete.new( operation.database, operation.collection, operation.selector ) session.with(consistency: :strong) do |session| session.execute delete 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 login(database, username, password) auth[database.to_s] = [username, password] 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 self.get_sql_like(attr_names, keyword) key = ActiveRecord::Base.connection.quote("%#{SqlHelper.escape_for_like(keyword)}%") con = [] attr_names.each do |attr_name| con << "(#{attr_name} like #{key})" end sql = con.join(' or ') sql = '(' + sql + ')' if con.length > 1 return sql 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 test_upload_binaries ActionController::IntegrationTest::reset_auth post "/build/home:Iggy/10.2/i586/TestPack", nil assert_response 401 prepare_request_with_user "adrian", "so_alone" post "/build/home:Iggy/10.2/i586/TestPack", nil assert_response 403 prepare_request_with_user "king", "sunflower" post "/build/home:Iggy/10.2/i586/TestPack", nil assert_response 400 # actually a success, it reached the backend assert_tag :tag => "status", :attributes => { :code => "400", :origin => "backend" } # check not supported methods post "/build/home:Iggy/10.2/i586/_repository", nil assert_response 404 assert_tag :tag => "status", :attributes => { :code => "unknown_package" } put "/build/home:Iggy/10.2/i586/TestPack", nil assert_response 400 assert_tag :tag => "status", :attributes => { :code => "invalid_http_method" } delete "/build/home:Iggy/10.2/i586/TestPack" assert_response 400 assert_tag :tag => "status", :attributes => { :code => "invalid_http_method" } end
1
Ruby
CWE-434
Unrestricted Upload of File with Dangerous Type
The software allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment.
https://cwe.mitre.org/data/definitions/434.html
safe
def get_folder_items Log.add_info(request, params.inspect) unless params[:thetisBoxSelKeeper].blank? @folder_id = params[:thetisBoxSelKeeper].split(':').last end begin if Folder.check_user_auth(@folder_id, @login_user, 'r', true) @items = Folder.get_items(@login_user, @folder_id) end rescue => evar Log.add_error(request, evar) end submit_url = url_for(:controller => 'schedules', :action => 'get_folder_items') render(:partial => 'common/select_items', :layout => false, :locals => {:target_attr => :id, :submit_url => submit_url}) 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 sanitize_string(host) if host.start_with?(".") /\A(.+\.)?#{Regexp.escape(host[1..-1])}\z/i else /\A#{Regexp.escape host}\z/i end end
0
Ruby
CWE-601
URL Redirection to Untrusted Site ('Open Redirect')
A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.
https://cwe.mitre.org/data/definitions/601.html
vulnerable
def add_fence_level(session, level, devices, node, remove = false) if not remove stdout, stderr, retval = run_cmd( session, PCS, "stonith", "level", "add", level, node, devices ) return retval,stdout, stderr else stdout, stderr, retval = run_cmd( session, PCS, "stonith", "level", "remove", level, node, devices ) return retval,stdout, 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
it "should use the sender address is no return path is specified" 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" 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 self.get_using_size(mail_account_id, add_con=nil) SqlHelper.validate_token([mail_account_id]) con = [] con << "(mail_account_id=#{mail_account_id})" con << "(#{add_con})" unless add_con.nil? or add_con.empty? return (Email.count_by_sql("select SUM(size) from emails where #{con.join(' and ')}") || 0) 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 comments_closed? !(allow_comments? && in_feedback_window?) 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 set_disp_ctrl Log.add_info(request, params.inspect) return unless request.post? folder_id = params[:id] SqlHelper.validate_token([folder_id]) if Folder.check_user_auth(folder_id, @login_user, 'w', true) @folder = Folder.find(folder_id) disp_ctrls = [] check_bbs_top = params[:check_bbs_top] if check_bbs_top == '1' disp_ctrls << Folder::DISPCTRL_BBS_TOP end select_sorting = params[:select_sorting] unless select_sorting.nil? disp_ctrls << Folder::DISPCTRL_DEF_SORT+'='+select_sorting end if disp_ctrls.empty? @folder.update_attribute(:disp_ctrl, nil) else @folder.update_attribute(:disp_ctrl, '|'+disp_ctrls.join('|')+'|') end flash[:notice] = t('msg.update_success') else flash[:notice] = 'ERROR:' + t('folder.need_auth_to_modify') end render(:partial => 'ajax_disp_ctrl', :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 "handles Symbol keys" do cl = subject.build_command_line("true", :abc => "def") expect(cl).to eq "true --abc def" 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 add_group( group, role ) check_write_access! unless role.kind_of? Role role = Role.get_by_title(role) end if role.global #only nonglobal roles may be set in a project raise SaveError, "tried to set global role '#{role_title}' for group '#{group}' in package '#{self.name}'" end unless group.kind_of? Group group = Group.find_by_title(group.to_s) end PackageGroupRoleRelationship.create( :package => self, :group => group, :role => role ) 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 test_auth_plain sock = FakeSocket.new smtp = Net::SMTP.new 'localhost', 25 smtp.instance_variable_set :@socket, sock assert smtp.auth_plain("foo", "bar").success? assert_equal "AUTH PLAIN AGZvbwBiYXI=\r\n", sock.write_io.string 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
def self.trim_by_capacity(user_id, mail_account_id, capacity_mb) # FEATURE_MAIL_STRICT_CAPACITY >>> =begin # max_size = capacity_mb * 1024 * 1024 # cur_size = MailAccount.get_using_size(mail_account_id) # # if cur_size > max_size # over_size = cur_size - max_size # emails = [] # # # First, empty Trashbox # user = User.find(user_id) # trashbox = MailFolder.get_for(user, mail_account_id, MailFolder::XTYPE_TRASH) # trash_nodes = [trashbox.id.to_s] # trash_nodes += MailFolder.get_childs(trash_nodes.first, true, false) # con = "mail_folder_id in (#{trash_nodes.join(',')})" # emails = Email.where(con).order('updated_at ASC').to_a # emails.each do |email| # next if email.size.nil? # # email.destroy # over_size -= email.size # break if over_size <= 0 # end # # # Now, remove others # if over_size > 0 # emails = Email.where("mail_account_id=#{mail_account_id.to_i}").order('updated_at ASC').to_a # emails.each do |email| # next if email.size.nil? # # email.destroy # over_size -= email.size # break if over_size <= 0 # end # end # end =end # FEATURE_MAIL_STRICT_CAPACITY <<< 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_for(user_id, fiscal_year=nil) SqlHelper.validate_token([user_id, fiscal_year]) begin con = [] con << "(user_id=#{user_id})" if fiscal_year.nil? return PaidHoliday.where(con).order('year ASC').to_a else con << "(year=#{fiscal_year})" return PaidHoliday.where(con.join(' and ')).first end rescue end 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
it 'should not choke on valueless attributes' do @s.fragment('foo <a href>foo</a> bar') .must_equal 'foo <a href="" rel="nofollow">foo</a> bar' 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 generate(time, inc = 0) pid = Process.pid % 0xFFFF [ time >> 24 & 0xFF, # 4 bytes time (network order) time >> 16 & 0xFF, time >> 8 & 0xFF, time & 0xFF, @machine_id[0], # 3 bytes machine @machine_id[1], @machine_id[2], pid >> 8 & 0xFF, # 2 bytes process id pid & 0xFF, inc >> 16 & 0xFF, # 3 bytes increment inc >> 8 & 0xFF, inc & 0xFF, ] 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_destroy @model.hosts.clear @model.interfaces.clear @model.domains.clear delete :destroy, {:id => @model}, set_session_user assert_redirected_to subnets_url refute Subnet.exists?(@model.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
def test_execute_details spec_fetcher do |fetcher| fetcher.spec 'a', 2 do |s| s.summary = 'This is a lot of text. ' * 4 s.authors = ['Abraham Lincoln', 'Hirohito'] s.homepage = 'http://a.example.com/' 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-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
def self.save_value(user_id, category, key, value) 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 if value.nil? unless setting.nil? setting.destroy end else if setting.nil? setting = Setting.new setting.user_id = user_id setting.category = category setting.xkey = key setting.xvalue = value setting.save! else setting.update_attribute(:xvalue, value) 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
def order_by order_option = '' if self.order_column direction = self.order_direction || 'ASC' order_option = "#{self.order_column} #{direction}" end order_option.present? ? order_option : @@default_order 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 add_acl_permission(session, acl_role_id, perm_type, xpath_id, query_id) stdout, stderror, retval = run_cmd( session, PCS, "acl", "permission", "add", acl_role_id.to_s, perm_type.to_s, xpath_id.to_s, query_id.to_s ) if retval != 0 if stderror.empty? return "Error adding permission" else return stderror.join("\n").strip end end return "" 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 update Log.add_info(request, params.inspect) return unless request.post? @address = Address.find(params[:id]) @address.attributes = params[:address] @address = AddressbookHelper.arrange_per_scope(@address, @login_user, params[:scope], params[:groups], params[:teams]) if @address.nil? flash[:notice] = t('msg.need_to_be_owner') redirect_to(:controller => 'desktop', :action => 'show') return end if @address.save flash[:notice] = t('msg.update_success') if request.xhr? render(:partial => 'common/flash_notice', :layout => false) else list render(:action => 'list') end else render(:controller => 'addressbook', :action => 'edit', :layout => (!request.xhr?)) 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 process_preflight(env) result = Result.preflight(env) resource, error = match_resource(env) unless resource result.miss(error) return {} end return resource.process_preflight(env, result) 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
it "respects #sort" do users.find(scope: scope).sort(_id: -1).one.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 from_time(time, options = {}) from_data(options[:unique] ? @@generator.next(time.to_i) : [ time.to_i ].pack("Nx8")) 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 "does not reject is content_type is empty but otherwise checks out" do file = File.open(fixture_file("empty.html")) assert ! Paperclip::MediaTypeSpoofDetector.using(file, "empty.html", "").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 ==(other) @host == other.host && @port == other.port 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 ismaster_command?(incoming_message) data = StringIO.new(incoming_message) data.read(20) # header and flags data.gets("\x00") # collection name data.read(8) # skip/limit selector = Moped::BSON::Document.deserialize(data) selector == { "ismaster" => 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 remove_constraint(session, constraint_id) stdout, stderror, retval = run_cmd( session, PCS, "constraint", "remove", constraint_id ) $logger.info stdout return retval 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 get_avail_fence_agents(params, request, session) if not allowed_for_local_cluster(session, Permissions::READ) return 403, 'Permission denied' end agents = getFenceAgents(session) return JSON.generate(agents) 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 self.save_group_value(group_id, category, key, value) 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 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
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 distinct values for +key+" do users.insert(documents) users.find(scope: scope).distinct(:count).should =~ [0, 1] 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 "creates an index with the provided name" do indexes.create(key, name: "custom_index_name") indexes[key]["name"].should eq "custom_index_name" 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 render_with_explicit_unescaped_template render :template => "test/h*llo_world" 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 get_stonith_agents_avail(session) code, result = send_cluster_request_with_token( session, params[:cluster], 'get_avail_fence_agents' ) return {} if 200 != code begin sa = JSON.parse(result) if (sa["noresponse"] == true) or (sa["notauthorized"] == "true") or (sa["notoken"] == true) or (sa["pacemaker_not_running"] == true) return {} else return sa end rescue JSON::ParserError return {} 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 alive? if Kernel::select([self], nil, nil, 0) !eof? rescue false else true 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 make_hs256_token(payload = nil) payload = { sub: 'abc123' } if payload.nil? JWT.encode payload, client_secret, 'HS256' 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
def move Log.add_info(request, params.inspect) return unless request.post? @group = Group.find(params[:id]) unless params[:thetisBoxSelKeeper].blank? parent_id = params[:thetisBoxSelKeeper].split(':').last childs = @group.get_childs(true, false) if childs.include?(parent_id) or (@group.id == parent_id.to_i) flash[:notice] = 'ERROR:' + t('group.cannot_be_parent') redirect_to(:action => 'show_tree') return end @group.parent_id = parent_id @group.xorder = nil @group.save end redirect_to(:action => 'show_tree') rescue => evar Log.add_error(request, evar) redirect_to(:action => 'show_tree') 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 __bson_dump__(io, key) io << Types::OBJECT_ID io << key io << NULL_BYTE io << data.pack('C12') 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 self.get_group_folder(group_id) SqlHelper.validate_token([group_id]) begin return Folder.where("(owner_id=#{group_id}) and (xtype='#{Folder::XTYPE_GROUP}')").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 gate_process HistoryHelper.keep_last(request) @login_user = User.find(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
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 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-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 "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 refresh info = command "admin", ismaster: 1 @refreshed_at = Time.now primary = true if info["ismaster"] secondary = true if info["secondary"] peers = [] peers.push info["primary"] if info["primary"] peers.concat info["hosts"] if info["hosts"] peers.concat info["passives"] if info["passives"] peers.concat info["arbiters"] if info["arbiters"] @peers = peers.map { |peer| Node.new(peer) } @primary, @secondary = primary, secondary if !primary && Threaded.executing?(:ensure_primary) raise Errors::ReplicaSetReconfigured, "#{inspect} is no longer the primary node." 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 test_destroy subnet = Subnet.first subnet.hosts.clear subnet.interfaces.clear subnet.domains.clear delete :destroy, {:id => subnet}, set_session_user assert_redirected_to subnets_url assert !Subnet.exists?(subnet.id) 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 tmp_dir ENV['TMPDIR'] || ENV['TEMP'] || '/tmp' end
0
Ruby
CWE-310
Cryptographic Issues
Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.
https://cwe.mitre.org/data/definitions/310.html
vulnerable
it "executes a distinct command" do database.should_receive(:command).with( distinct: collection.name, key: "name", query: selector ).and_return("values" => [ "durran", "bernerd" ]) query.distinct(:name) 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 legal?(string) string.to_s =~ /^[0-9a-f]{24}$/i ? true : 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
def self.get_for(user_id, category=nil) SqlHelper.validate_token([user_id, category]) con = [] con << "(user_id=#{user_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
def sync_server(server) [].tap do |hosts| socket = server.socket if socket.connect info = socket.simple_query Protocol::Command.new(:admin, ismaster: 1) if info["ismaster"] server.primary = true end if info["secondary"] server.secondary = true end if info["primary"] hosts.push info["primary"] end if info["hosts"] hosts.concat info["hosts"] end if info["passives"] hosts.concat info["passives"] end merge(server) end end.uniq 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 team_organize Log.add_info(request, params.inspect) team_id = params[:team_id] unless team_id.blank? 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.blank? # @team must not be nil. @team.save if modified = @team.clear_users 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
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 secondaries servers.select(&:secondary?) 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.delete_statistics_group(group_id) yaml = Research.get_config_yaml if yaml.nil? or yaml[:statistics].nil? return [] end groups = yaml[:statistics][:groups] return [] if groups.nil? ary = groups.split('|') ary.delete group_id.to_s ary.compact! ary.delete '' yaml[:statistics][:groups] = ary.join('|') Research.save_config_yaml yaml return ary 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 filename = Rails.root.join("attachments", @attachment.filename) unless File.exist?(filename) COURSE_LOGGER.log("Cannot find the file '#{@attachment.filename}' for"\ " attachment #{@attachment.name}") flash[:error] = "Error loading #{@attachment.name} from #{@attachment.filename}" redirect_to([@course, :attachments]) && return end send_file(filename, disposition: "inline", type: @attachment.mime_type, filename: @attachment.filename) && return 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 "syncs the cluster" do cluster.should_receive(:sync) do cluster.servers << server end 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 get_auth_users Log.add_info(request, params.inspect) begin @folder = Folder.find(params[:id]) rescue @folder = nil end @users = [] session[:folder_id] = params[:id] if !@login_user.nil? and (@login_user.admin?(User::AUTH_FOLDER) or ([email protected]? and @folder.in_my_folder_of?(@login_user.id))) render(:partial => 'ajax_auth_users', :layout => false) else render(:partial => 'ajax_auth_disp', :layout => false) 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 return nil if there is not key' do expect(jwt_validator.jwks_key(:auth0, jwks_kid)).to eq(nil) 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
def set_description Log.add_info(request, params.inspect) if params[:id].nil? or params[:id].empty? @item = Item.new_info(0) @item.attributes = params.require(:item).permit(Item::PERMIT_BASE) @item.user_id = @login_user.id @item.title = t('paren.no_title') @item.save else @item = Item.find(params[:id]) @item.update_attributes(params.require(:item).permit(Item::PERMIT_BASE)) end render(:partial => 'ajax_item_description', :layout => false) rescue => evar Log.add_error(request, evar) render(:partial => 'ajax_item_description', :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 "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 @object.select(@request).should == :file_server 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 each cursor = Cursor.new(session.with(retain_socket: true), operation) cursor.to_enum.tap do |enum| enum.each do |document| yield document end if block_given? 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
it "returns true" do session.should be_safe 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 queue Threaded.stack(:pipelined_operations) 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_tree_by_group_for_admin(group_id) SqlHelper.validate_token([group_id]) folder_tree = {} tree_id = '0' if group_id.to_s == '0' sql = 'select distinct * from folders' where = " where (parent_id = #{tree_id})" where << " and ((xtype is null) or not(xtype = '#{XTYPE_GROUP}' or xtype = '#{XTYPE_USER}'))" order_by = ' order by xorder ASC, id ASC' else sql = 'select distinct Folder.* from folders Folder, users User' where = " where (Folder.parent_id = #{tree_id})" where << ' and (' where << "(Folder.xtype = '#{XTYPE_GROUP}' and Folder.owner_id = #{group_id})" where << ' or ' where << "(Folder.xtype = '#{XTYPE_USER}' and Folder.owner_id = User.id and #{SqlHelper.get_sql_like(['User.groups'], "|#{group_id}|")})" where << ' )' order_by = ' order by Folder.xorder ASC, Folder.id ASC' end sql << where + order_by folder_tree[tree_id] = Folder.find_by_sql(sql) folder_tree[tree_id].each do |folder| folder_tree = Folder.get_tree(folder_tree, nil, folder, true) end return Folder.sort_tree(folder_tree) 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 check_default_at_signup_permissions all_permissions = Permission.all.pluck(:id) admin_permissions = Permission.where('name LIKE ? OR name = ?', 'admin%', 'ticket.agent').pluck(:id) # admin.*/ticket.agent permissions normal_permissions = (all_permissions - admin_permissions) | (admin_permissions - all_permissions) # all other permissions besides admin.*/ticket.agent return true if default_at_signup != true # means if default_at_signup = false, no need further checks return true if self.permission_ids.all? { |i| normal_permissions.include? i } # allow user to choose only normal permissions raise Exceptions::UnprocessableEntity, 'Cannot set default at signup when role has admin or ticket.agent permissions.' end
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
def sync_server(server) [].tap do |hosts| socket = server.socket if socket.connect info = socket.simple_query Protocol::Command.new(:admin, ismaster: 1) if info["ismaster"] server.primary = true end if info["secondary"] server.secondary = true end if info["primary"] hosts.push info["primary"] end if info["hosts"] hosts.concat info["hosts"] end if info["passives"] hosts.concat info["passives"] end merge(server) end end.uniq 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 "yields the new session" do session.stub(with: new_session) session.new(new_options) do |session| session.should eql new_session 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
it "raises no exception" do lambda do cluster.sync_server server end.should_not raise_exception 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 "rejects #{node.inspect}" do @report.host = node expect { @report.process }.to raise_error(ArgumentError, /Invalid node/) 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_by_email(mail_addr, user, book=Address::BOOK_BOTH) SqlHelper.validate_token([mail_addr]) email_con = [] email_con.push("(email1='#{mail_addr}')") email_con.push("(email2='#{mail_addr}')") email_con.push("(email3='#{mail_addr}')") con = [] con.push('('+email_con.join(' or ')+')') con.push(AddressbookHelper.get_scope_condition_for(user, book)) return Address.where(con.join(' and ')).to_a 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_owners name response = rubygems_api_request :get, "api/v1/gems/#{name}/owners.yaml" do |request| request.add_field "Authorization", api_key end with_response response do |resp| owners = YAML.load resp.body say "Owners for gem: #{name}" owners.each do |owner| say "- #{owner['email'] || owner['handle'] || owner['id']}" end end 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 to_s to_bson.unpack("H*")[0].force_encoding(UTF8) 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 delete_attachment Log.add_info(request, '') # Not to show passwords. 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
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.get_tree(klass, tree, conditions, node_id, order_by) SqlHelper.validate_token([node_id]) if conditions.nil? con = '' else con = Marshal.load(Marshal.dump(conditions)) + ' and ' end con << "(parent_id=#{node_id.to_i})" tree[node_id] = klass.where(con).order(order_by).to_a tree[node_id].each do |node| tree = klass.get_tree(tree, conditions, node.id.to_s) end return tree 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 delete_statistics_group Log.add_info(request, params.inspect) group_id = params[:group_id] if group_id.nil? or group_id.empty? @group_ids = Research.get_statistics_groups render(:partial => 'ajax_statistics_groups', :layout => false) return end @group_ids = Research.delete_statistics_group group_id render(:partial => 'ajax_statistics_groups', :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 add_role(what, role) check_write_access! self.transaction do if what.kind_of? Group self.package_group_role_relationships.create!(role: role, group: what) else self.package_user_role_relationships.create!(role: role, user: what) end write_to_backend end 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 stub_bad_jwks stub_request(:get, 'https://samples.auth0.com/.well-known/jwks-bad.json') .to_return( status: 404 ) 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
def get_items_order Log.add_info(request, params.inspect) @folder_id = params[:id] SqlHelper.validate_token([@folder_id]) if @folder_id != '0' begin @folder = Folder.find(@folder_id) rescue => evar @folder = nil Log.add_error(request, evar) end end if Folder.check_user_auth(@folder_id, @login_user, 'r', true) if !@login_user.nil? and @login_user.admin?(User::AUTH_ITEM) @items = Folder.get_items_admin(@folder_id, 'xorder ASC') else @items = Folder.get_items(@login_user, @folder_id, 'xorder ASC') end end session[:folder_id] = @folder_id render(:partial => 'ajax_items_order', :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 store(opts = {}) # no write access check here, since this operation may will disable this permission ... @commit_opts = opts save! 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 test_update_valid put :update, {:id => hostgroups(:common), :hostgroup => { :name => hostgroups(:common).name }}, set_session_user assert_redirected_to hostgroups_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 hash [ip_address, port].hash 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 logging(operations, &block) Support::Stats.record(self, operations) _logging(operations, &block) 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 return :file if the request key is fully qualified" do @request.expects(:key).returns File.expand_path('/foo') @object.select_terminus(@request).should == :file 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 tags_for_index(model) model.tags.inject("".html_safe) do |out, tag| query = controller.send(:current_query) || "" hashtag = "##{tag}" if query.empty? query = hashtag elsif !query.include?(hashtag) query += " #{hashtag}" end out << link_to_function(tag, "crm.search_tagged('#{query}', '#{model.class.to_s.tableize}')", title: tag) 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
def validate_line(line) # A bare CR or LF is not allowed in RFC5321. if /[\r\n]/ =~ line raise ArgumentError, "A line must not contain CR or LF" end 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
def initialize(seeds, direct = false) @seeds = seeds @direct = direct @servers = [] @dynamic_seeds = [] 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 get_official_titles Log.add_info(request, params.inspect) @group_id = (params[:id] || '0') # '0' for ROOT SqlHelper.validate_token([@group_id]) session[:group_id] = params[:id] session[:group_option] = 'official_title' render(:partial => 'ajax_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 email user_info['email'] || id_info['email'] end
0
Ruby
CWE-290
Authentication Bypass by Spoofing
This attack-focused weakness is caused by improperly implemented authentication schemes that are subject to spoofing attacks.
https://cwe.mitre.org/data/definitions/290.html
vulnerable
def ==(other) return false unless other.is_a?(ObjectId) to_bson == other.to_bson 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_user_archive_fields(user_archive) user_archive_array = [] topic_data = user_archive.topic user_archive = user_archive.as_json topic_data = Topic.with_deleted.find_by(id: user_archive['topic_id']) if topic_data.nil? return user_archive_array if topic_data.nil? categories = piped_category_name(topic_data.category_id) is_pm = topic_data.archetype == "private_message" ? I18n.t("csv_export.boolean_yes") : I18n.t("csv_export.boolean_no") url = "#{Discourse.base_url}/t/#{topic_data.slug}/#{topic_data.id}/#{user_archive['post_number']}" topic_hash = { "post" => user_archive['raw'], "topic_title" => topic_data.title, "categories" => categories, "is_pm" => is_pm, "url" => url } user_archive.merge!(topic_hash) HEADER_ATTRS_FOR['user_archive'].each do |attr| user_archive_array.push(user_archive[attr]) end user_archive_array 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 promote @primary = true @secondary = false hiccup 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-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 testLoginByToken users = [] users << {"username" => "user1", "token" => "token1"} users << {"username" => "user2", "token" => "token2"} users << {"username" => SUPERUSER, "token" => "tokenS"} password_file = File.open($user_pass_file, File::RDWR|File::CREAT) password_file.truncate(0) password_file.rewind password_file.write(JSON.pretty_generate(users)) password_file.close() session = {} cookies = {} result = PCSAuth.loginByToken(session, cookies) assert_equal(false, result) assert_equal({}, session) session = {} cookies = {'token' => 'tokenX'} result = PCSAuth.loginByToken(session, cookies) assert_equal(false, result) assert_equal({}, session) session = {} cookies = {'token' => 'token1'} result = PCSAuth.loginByToken(session, cookies) assert_equal(true, result) assert_equal( {:username => 'user1', :usergroups => ['group1', 'haclient']}, session ) session = {} cookies = { 'token' => 'token1', 'CIB_user' => 'userX', 'CIB_user_groups' => PCSAuth.cookieUserEncode('groupX') } result = PCSAuth.loginByToken(session, cookies) assert_equal(true, result) assert_equal( {:username => 'user1', :usergroups => ['group1', 'haclient']}, session ) session = {} cookies = {'token' => 'tokenS'} result = PCSAuth.loginByToken(session, cookies) assert_equal(true, result) assert_equal( {:username => SUPERUSER, :usergroups => []}, session ) session = {} cookies = { 'token' => 'tokenS', 'CIB_user' => 'userX', 'CIB_user_groups' => PCSAuth.cookieUserEncode('groupX') } result = PCSAuth.loginByToken(session, cookies) assert_equal(true, result) assert_equal( {:username => 'userX', :usergroups => ['groupX']}, 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 self.search_by_user(key, operator, value) key_name = key.sub(/^.*\./,'') users = User.all(:conditions => "#{key_name} #{operator} '#{value_to_sql(operator, value)}'") hosts = users.map(&:hosts).flatten opts = hosts.empty? ? "= 'nil'" : "IN (#{hosts.map(&:id).join(',')})" return {:conditions => " hosts.id #{opts} " } 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.trim(user_id, mail_account_id, max) SqlHelper.validate_token([user_id, mail_account_id]) begin count = Email.where("mail_account_id=#{mail_account_id.to_i}").count if count > max #logger.fatal("[INFO] Email.trim(user_id:#{user_id}, mail_account_id:#{mail_account_id}, max:#{max})") over_num = count - max emails = [] # First, empty Trashbox user = User.find(user_id) trashbox = MailFolder.get_for(user, mail_account_id, MailFolder::XTYPE_TRASH) trash_nodes = [trashbox.id.to_s] trash_nodes += MailFolder.get_childs(trash_nodes.first, true, false) con = "mail_folder_id in (#{trash_nodes.join(',')})" emails = Email.where(con).order('updated_at ASC').limit(over_num).to_a # Now, remove others if emails.length < over_num over_num -= emails.length emails += Email.where("mail_account_id=#{mail_account_id.to_i}").order('updated_at ASC').limit(over_num).to_a end emails.each do |email| email.destroy end end rescue 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 schedule_all Log.add_info(request, params.inspect) date_s = params[:date] if date_s.nil? or date_s.empty? @date = Date.today else @date = Date.parse(date_s) end if @login_user.nil? or params[:display].nil? or params[:display] == 'all' params[:display] = 'all' con = EquipmentHelper.get_scope_condition_for(@login_user) else display_type = params[:display].split('_').first display_id = params[:display].split('_').last case display_type when 'group' if @login_user.get_groups_a(true).include?(display_id) con = ApplicationHelper.get_sql_like([:groups], "|#{display_id}|") end when 'team' if @login_user.get_teams_a.include?(display_id) con = ApplicationHelper.get_sql_like([:teams], "|#{display_id}|") 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
def self.search_by_puppetclass(key, operator, value) conditions = "puppetclasses.name #{operator} '#{value_to_sql(operator, value)}'" hosts = Host.my_hosts.all(:conditions => conditions, :joins => :puppetclasses, :select => 'DISTINCT hosts.id').map(&:id) host_groups = Hostgroup.all(:conditions => conditions, :joins => :puppetclasses, :select => 'DISTINCT hostgroups.id').map(&:id) opts = '' opts += "hosts.id IN(#{hosts.join(',')})" unless hosts.blank? opts += " OR " unless hosts.blank? || host_groups.blank? opts += "hostgroups.id IN(#{host_groups.join(',')})" unless host_groups.blank? opts = "hosts.id < 0" if hosts.blank? && host_groups.blank? return {:conditions => opts, :include => :hostgroup} 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 check_owner return if params[:id].nil? or params[:id].empty? or @login_user.nil? begin owner_id = Item.find(params[:id]).user_id rescue owner_id = -1 end if !@login_user.admin?(User::AUTH_ITEM) 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
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-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