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 group Log.add_info(request, params.inspect) date_s = params[:date] if date_s.blank? @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 SqlHelper.validate_token([display_id]) @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
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 params super rescue Rack::Utils::ParameterTypeError, Rack::Utils::InvalidParameterError => e raise BadRequest, "Invalid query parameters: #{e.message}" 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 stub_jwks stub_request(:get, 'https://samples.auth0.com/.well-known/jwks.json') .to_return( headers: { 'Content-Type' => 'application/json' }, body: jwks.to_json, status: 200 ) 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
it "should return :file if the request key is fully qualified" do @request.expects(:key).returns File.expand_path('/foo') @object.select(@request).should == :file 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 to_json(options = nil) [name].to_json end
1
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
safe
def test_create_maintenance_project_and_maintained_project User.current = users( :king ) maintenance_project = Project.new(:name => 'Maintenance:Project') assert_equal true, maintenance_project.set_project_type('maintenance') assert_equal 'maintenance', maintenance_project.project_type() # Create a project for which maintenance is done (i.e. a maintained project) maintained_project = Project.new(:name => 'Maintained:Project') assert_equal true, maintained_project.set_maintenance_project(maintenance_project) assert_equal true, maintained_project.set_maintenance_project(maintenance_project.name) assert_equal maintenance_project, maintained_project.maintenance_project() 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 return a 403 if a user attempts to get at the _diagnostics path" do get "/message-bus/_diagnostics" last_response.status.must_equal 403 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 "updates the selector to mongo's advanced selector" do query.sort(a: 1) query.operation.selector.should eq( "$query" => selector, "$orderby" => { a: 1 } ) end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
it "sets the generation time" do time = Time.at((Time.now.utc - 64800).to_i).utc Moped::BSON::ObjectId.new(nil, time).generation_time.should == time 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.safe_load input ::YAML.safe_load(input, WHITELISTED_CLASSES, WHITELISTED_SYMBOLS, true) 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 rs256_decode_key(kid) jwks_x5c = jwks_key(:x5c, kid) if jwks_x5c.nil? raise OmniAuth::Auth0::TokenValidationError.new("Could not find a public key for Key ID (kid) '#{kid}''") end jwks_public_cert(jwks_x5c.first) 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 select_terminus(request) # We rely on the request's parsing of the URI. # Short-circuit to :file if it's a fully-qualified path or specifies a 'file' protocol. return PROTOCOL_MAP["file"] if Puppet::Util.absolute_path?(request.key) return PROTOCOL_MAP["file"] if request.protocol == "file" # We're heading over the wire the protocol is 'puppet' and we've got a server name or we're not named 'apply' or 'puppet' if request.protocol == "puppet" and (request.server or !["puppet","apply"].include?(Puppet.settings[:name])) return PROTOCOL_MAP["puppet"] end if request.protocol and PROTOCOL_MAP[request.protocol].nil? raise(ArgumentError, "URI protocol '#{request.protocol}' is not currently supported for file serving") end # If we're still here, we're using the file_server or modules. :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_comment_of(item_id, user_id) SqlHelper.validate_token([item_id, user_id]) begin comment = Comment.where("(user_id=#{user_id.to_i}) and (item_id=#{item_id.to_i}) and (xtype='#{Comment::XTYPE_DIST_ACK}')").first rescue => evar Log.add_error(nil, evar) end return comment 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_verify_duplicate_file FileUtils.mkdir_p 'lib' FileUtils.touch 'lib/code.rb' build = Gem::Package.new @gem build.spec = @spec build.setup_signer open @gem, 'wb' do |gem_io| Gem::Package::TarWriter.new gem_io do |gem| build.add_metadata gem build.add_contents gem gem.add_file_simple 'a.sig', 0444, 0 gem.add_file_simple 'a.sig', 0444, 0 end end package = Gem::Package.new @gem e = assert_raises Gem::Security::Exception do package.verify end assert_equal 'duplicate files in the package: ("a.sig")', e.message end
1
Ruby
CWE-347
Improper Verification of Cryptographic Signature
The software does not verify, or incorrectly verifies, the cryptographic signature for data.
https://cwe.mitre.org/data/definitions/347.html
safe
def ensure_connected # Don't run the reconnection login if we're already inside an # +ensure_connected+ block. return yield if Threaded.executing? :connection Threaded.begin :connection retry_on_failure = true begin connect unless connected? yield rescue Errors::ReplicaSetReconfigured # Someone else wrapped this in an #ensure_primary block, so let the # reconfiguration exception bubble up. raise rescue Errors::OperationFailure, Errors::AuthenticationFailure, Errors::QueryFailure # These exceptions are "expected" in the normal course of events, and # don't necessitate disconnecting. raise rescue Errors::ConnectionFailure disconnect if retry_on_failure # Maybe there was a hiccup -- try reconnecting one more time retry_on_failure = false retry else # Nope, we failed to connect twice. Flag the node as down and re-raise # the exception. down! raise end rescue # Looks like we got an unexpected error, so we'll clean up the connection # and re-raise the exception. disconnect raise $!.extend(Errors::SocketError) end ensure Threaded.end :connection
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_bad_early_options assert_raise HgCommandArgumentError do @adapter.diff('sources/welcome_controller.rb', '--config=alias.rhdiff=!xterm') end assert_raise HgCommandArgumentError do @adapter.entries('--debugger') end assert_raise HgCommandArgumentError do @adapter.revisions(nil, nil, nil, limit: '--repo=otherrepo') end assert_raise HgCommandArgumentError do @adapter.nodes_in_branch('default', limit: '--repository=otherrepo') end assert_raise HgCommandArgumentError do @adapter.nodes_in_branch('-Rotherrepo') end end
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
it "stores the collection name" do collection.name.should eq :users end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
it 'should not update roles' do expect { spree_put :update, { :user => { :spree_role_ids => [role.id] } }}.to raise_exception(ActiveModel::MassAssignmentSecurity::Error) end
1
Ruby
CWE-264
Permissions, Privileges, and Access Controls
Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.
https://cwe.mitre.org/data/definitions/264.html
safe
def update return unless access_granted?(params[:id]) id = params[:article][:id] || params[:id] @article = Article.find(id) if params[:article][:draft] fetch_fresh_or_existing_draft_for_article else @article = Article.find(@article.parent_id) unless @article.parent_id.nil? end update_article_attributes if @article.draft @article.state = "draft" elsif @article.draft? @article.publish! end if @article.save Article.where(parent_id: @article.id).map(&:destroy) unless @article.draft flash[:success] = I18n.t("admin.content.update.success") redirect_to action: "index" else @article.keywords = Tag.collection_to_string @article.tags load_resources render "edit" end end
0
Ruby
CWE-732
Incorrect Permission Assignment for Critical Resource
The product specifies permissions for a security-critical resource in a way that allows that resource to be read or modified by unintended actors.
https://cwe.mitre.org/data/definitions/732.html
vulnerable
it "initializes with the strings bytes" do Moped::BSON::ObjectId.should_receive(:new).with(bytes) Moped::BSON::ObjectId.from_string "4e4d66343b39b68407000001" end
0
Ruby
CWE-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 quote_column_name(name) #:nodoc: %Q("#{name}") end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def taxable_ids(loc = which_location, org = which_organization, inner_method = which_ancestry_method) if SETTINGS[:locations_enabled] && loc.present? inner_ids_loc = if Location.ignore?(self.to_s) self.unscoped.pluck("#{table_name}.id") else inner_select(loc, inner_method) end end
0
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
vulnerable
def get_mail_attachments Log.add_info(request, params.inspect) email_id = params[:id] email = Email.find_by_id(email_id) if email.nil? or email.user_id != @login_user.id render(:text => '') return end download_name = "mail_attachments#{email.id}.zip" zip_file = email.zip_attachments(params[:enc]) if zip_file.nil? send_data('', :type => 'application/octet-stream;', :disposition => 'attachment;filename="'+download_name+'"') else filepath = zip_file.path send_file(filepath, :filename => download_name, :stream => true, :disposition => 'attachment') 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 user_with_viewer_rights_should_fail_to_edit_a_domain setup_users get :edit, {:id => @model.id} assert @response.status == '403 Forbidden' 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_update_valid Subnet.any_instance.stubs(:valid?).returns(true) put :update, {:id => @model, :subnet => {:network => '192.168.100.10'}}, set_session_user assert_equal '192.168.100.10', Subnet.unscoped.find(@model).network assert_redirected_to subnets_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 generation_time Time.at(@data.pack("C4").unpack("N")[0]).utc 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 "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-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def initialize(database, command) super database, :$cmd, command, limit: -1 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 "creates an index with a generated name" do indexes.create(key) indexes[key]["name"].should eq "location.latlong_2d_name_1_age_-1" 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 comment_link(uniqueid, data) comment = comment_for_type(data) i18n_key = data[:cutoff] ? 'truncated' : 'full' notification = t( "notifications.comment.#{i18n_key}", name: data[:user], comment: strip_tags(data[:comment]), typename: data[:typename] ) notification_link(uniqueid, comment[:path], notification) 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 "removes all matching documents" do users.insert(documents) users.find(scope: scope).remove_all users.find(scope: scope).count.should eq 0 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 RelaxNG string_or_io RelaxNG.new(string_or_io) end
0
Ruby
CWE-611
Improper Restriction of XML External Entity Reference
The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
def index valid_http_methods :get, :post # for permission check if params[:package] and not ["_repository", "_jobhistory"].include?(params[:package]) pkg = DbPackage.get_by_project_and_name( params[:project], params[:package], use_source=false ) else prj = DbProject.get_by_name params[:project] end if request.get? pass_to_backend return end if @http_user.is_admin? # check for a local package instance DbPackage.get_by_project_and_name( params[:project], params[:package], follow_project_links=false ) pass_to_backend else render_error :status => 403, :errorcode => "execute_cmd_no_permission", :message => "Upload of binaries is only permitted for administrators" end 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 group 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 @group_id = params[:id] group_users = Group.get_users(params[:id]) @user_schedule_hash = {} unless group_users.nil? @holidays = Schedule.get_holidays group_users.each do |user| @user_schedule_hash[user.id.to_s] = Schedule.get_somebody_week(@login_user, user.id, @date, @holidays) end end params[:display] = params[:action] + '_' + params[:id] 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 get_avail_resource_agents(params, request, session) if not allowed_for_local_cluster(session, Permissions::READ) return 403, 'Permission denied' end agents = getResourceAgents(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.get_tmpl_folder tmpl_folder = Folder.where("folders.name='#{TMPL_ROOT}'").first if tmpl_folder.nil? ary = self.setup_tmpl_folder unless ary.nil? or ary.empty? tmpl_folder = ary[0] tmpl_system_folder = ary[1] tmpl_workflows_folder = ary[2] tmpl_local_folder = ary[3] tmpl_q_folder = ary[4] end else folders = Folder.where("parent_id=#{tmpl_folder.id}").to_a unless folders.nil? folders.each do |child| case child.name when TMPL_SYSTEM tmpl_system_folder = child when TMPL_WORKFLOWS tmpl_workflows_folder = child when TMPL_LOCAL tmpl_local_folder = child when TMPL_RESEARCH tmpl_q_folder = child end 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 digest_name; 'SHA512'; end
1
Ruby
CWE-347
Improper Verification of Cryptographic Signature
The software does not verify, or incorrectly verifies, the cryptographic signature for data.
https://cwe.mitre.org/data/definitions/347.html
safe
def spec_summary entry, spec summary = truncate_text(spec.summary, "the summary for #{spec.full_name}") entry << "\n\n" << format_text(summary, 68, 4) 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 realpath file File.realpath file 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 initialize(session) @session = session 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 close_clients_for(server) Moped.logger.debug "replica_set: closing open clients on #{server.port}" @clients.reject! do |client| port = client.addr(false)[1] if port == server.port client.close true else false 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 get_attachment Log.add_info(request, params.inspect) attach = Attachment.find(params[:id]) if attach.nil? redirect_to(THETIS_RELATIVE_URL_ROOT + '/404.html') return end parent_item = attach.item || ((attach.comment.nil?) ? nil : attach.comment.item) if parent_item.nil? or !parent_item.check_user_auth(@login_user, 'r', true) Log.add_check(request, '[Item.check_user_auth]'+request.to_s) redirect_to(:controller => 'frames', :action => 'http_error', :id => '401') return end attach_name = 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) } attach_name = CGI::escape(attach_name) unless ie_ver.nil? end begin attach_location = attach.location rescue attach_location = Attachment::LOCATION_DB # for lower versions end if attach_location == Attachment::LOCATION_DIR filepath = AttachmentsHelper.get_path(attach) send_file(filepath, :filename => attach_name, :stream => true, :disposition => 'attachment') else send_data(attach.content, :type => (attach.content_type || 'application/octet-stream')+';charset=UTF-8', :disposition => 'attachment;filename="'+attach_name+'"') 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 '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
NVD-CWE-noinfo
null
null
null
vulnerable
def self.get_default_for(user_id, xtype=nil) SqlHelper.validate_token([user_id, xtype]) con = [] con << "(user_id=#{user_id})" con << '(is_default=1)' con << "(xtype='#{xtype}')" unless xtype.blank? where = '' unless con.nil? or con.empty? where = 'where ' + con.join(' and ') end account_ary = MailAccount.find_by_sql('select * from mail_accounts ' + where + ' order by xorder ASC, title ASC') if account_ary.nil? or account_ary.empty? return nil else return account_ary.first 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 check_member return if params[:id].blank? or @login_user.nil? if Item.find(params[:id]).user_id != @login_user.id Log.add_check(request, '[check_member]'+request.to_s) flash[:notice] = t('team.need_to_be_member') 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 self.update_for(user_id, fiscal_year, num) SqlHelper.validate_token([user_id, fiscal_year]) if num <= 0 con = [] con << "(user_id=#{user_id})" con << "(year=#{fiscal_year})" PaidHoliday.destroy_all(con.join(' and ')) return end paid_holiday = PaidHoliday.get_for(user_id, fiscal_year) if paid_holiday.nil? paid_holiday = PaidHoliday.new paid_holiday.user_id = user_id paid_holiday.year = fiscal_year paid_holiday.num = num paid_holiday.save! else paid_holiday.update_attribute(:num, num) 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 reactions_given params.require(:username) user = fetch_user_from_params(include_inactive: current_user.try(:staff?) || (current_user && SiteSetting.show_inactive_accounts)) raise Discourse::NotFound unless guardian.can_see_profile?(user) reaction_users = DiscourseReactions::ReactionUser .joins(:reaction, :post) .includes(:user, :post, :reaction) .where(user_id: user.id) .where('discourse_reactions_reactions.reaction_users_count IS NOT NULL') if params[:before_reaction_user_id] reaction_users = reaction_users .where('discourse_reactions_reaction_users.id < ?', params[:before_reaction_user_id].to_i) end reaction_users = reaction_users .order(created_at: :desc) .limit(20) render_serialized(reaction_users.to_a, UserReactionSerializer) 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 dup session = super session.instance_variable_set :@options, options.dup if defined? @current_database session.send(:remove_instance_variable, :@current_database) end 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 create_fixed_clamp_code(nbits, signed) if nbits == 1 && signed == :signed raise "signed bitfield must have more than one bit" end if signed == :signed max = (1 << (nbits - 1)) - 1 min = -(max + 1) else min = 0 max = (1 << nbits) - 1 end clamp = "(val < #{min}) ? #{min} : (val > #{max}) ? #{max} : val" if nbits == 1 # allow single bits to be used as booleans clamp = "(val == true) ? 1 : (not val) ? 0 : #{clamp}" end "val = #{clamp}" end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def verify_cert_key_pair(cert, key) errors = [] cert_modulus = nil key_modulus = nil stdout, stderr, retval = run_cmd_options( PCSAuth.getSuperuserSession(), { 'stdin' => cert, }, '/usr/bin/openssl', 'x509', '-modulus', '-noout' ) if retval != 0 errors << "Invalid certificate: #{stderr.join}" else cert_modulus = stdout.join.strip end stdout, stderr, retval = run_cmd_options( PCSAuth.getSuperuserSession(), { 'stdin' => key, }, '/usr/bin/openssl', 'rsa', '-modulus', '-noout' ) if retval != 0 errors << "Invalid key: #{stderr.join}" else key_modulus = stdout.join.strip end if errors.empty? and cert_modulus and key_modulus if cert_modulus != key_modulus errors << 'Certificate does not match the key' end end return errors 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_more(*args) raise NotImplementedError, "#get_more 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
it "returns the new session" do session.stub(with: new_session) session.new(new_options).should eql new_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 ==(other) resolved_address == other.resolved_address 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 with_taxonomy_scope(loc = Location.current, org = Organization.current, inner_method = :subtree_ids) scope = block_given? ? yield : where(nil) return scope unless Taxonomy.enabled_taxonomies.present? self.which_ancestry_method = inner_method self.which_location = Location.expand(loc) if SETTINGS[:locations_enabled] self.which_organization = Organization.expand(org) if SETTINGS[:organizations_enabled] scope = scope_by_taxable_ids(scope) scope.readonly(false) 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 "should reject a critical extension that isn't on the whitelist" do @request.stubs(:request_extensions).returns [{ "oid" => "banana", "value" => "yumm", "critical" => true }] expect { @ca.sign(@name) }.to raise_error( Puppet::SSL::CertificateAuthority::CertificateSigningError, /request extensions that are not permitted/ ) 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 update_groups_order Log.add_info(request, params.inspect) return unless request.post? order_ary = params[:groups_order] groups = Group.get_childs(params[:id], false, false) # groups must be ordered by xorder ASC. groups.sort! { |id_a, id_b| idx_a = order_ary.index(id_a) idx_b = order_ary.index(id_b) if idx_a.nil? or idx_b.nil? idx_a = groups.index(id_a) idx_b = groups.index(id_b) end idx_a - idx_b } idx = 1 groups.each do |group_id| begin group = Group.find(group_id) group.update_attribute(:xorder, idx) idx += 1 rescue => evar group = nil Log.add_error(request, evar) end end render(:text => '') end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it "inserts the document" do session.should_receive(:execute).with do |insert| insert.documents.should eq [{a: 1}] end collection.insert(a: 1) 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 add_label options, f, attr label_size = options.delete(:label_size) || "col-md-2" required_mark = check_required(options, f, attr) label = options[:label] == :none ? '' : options.delete(:label) label ||= ((clazz = f.object.class).respond_to?(:gettext_translation_for_attribute_name) && s_(clazz.gettext_translation_for_attribute_name attr)) if f label = label.present? ? label_tag(attr, "#{label}#{required_mark}", :class => label_size + " control-label") : '' label 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
it "renders email addresses in the body" do comment = build_stubbed(:comment, body: "[email protected]") expect(comment.generate_html(:body)).to match(/mailto:/) 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 "only aquires the socket once" do session.cluster.should_receive(:socket_for). with(:read).once.and_return(mock(Moped::Socket)) session.send(:socket_for, :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
it "activates user invited via email with a token" do invite = Fabricate(:invite, invited_by: Fabricate(:admin), email: '[email protected]', emailed_status: Invite.emailed_status_types[:sent]) user = InviteRedeemer.create_user_from_invite(invite: invite, email: invite.email, username: 'walter', name: 'Walter White', email_token: invite.email_token) expect(user.username).to eq('walter') expect(user.name).to eq('Walter White') expect(user.email).to eq('[email protected]') expect(user.approved).to eq(true) expect(user.active).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
def get_path Log.add_info(request, params.inspect) if params[:thetisBoxSelKeeper].blank? @group_path = '/' + t('paren.unknown') render(:partial => 'ajax_group_path', :layout => false) return end @selected_id = params[:thetisBoxSelKeeper].split(':').last SqlHelper.validate_token([@selected_id]) @group_path = Group.get_path(@selected_id) render(:partial => 'ajax_group_path', :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 delete_holidays Log.add_info(request, params.inspect) return unless request.post? holidays = params[:holidays] unless holidays.nil? SqlHelper.validate_token([holidays]) holidays.each do |schedule_id| Schedule.destroy(schedule_id) end end @holidays = Schedule.get_holidays render(:partial => 'config_holidays', :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 "should not warn when matches against IP addresses fail" do add_rule("allow 10.1.1.2") @auth.should_not allow(request) @logs.should_not be_any {|log| log.level == :warning and log.message =~ /Authentication based on IP address is deprecated/} end
1
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
safe
def escape_for_shell Mail::ShellEscape.escape_for_shell(self) 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 "syncs each seed node" do server = Moped::Server.allocate Moped::Server.should_receive(:new).with("127.0.0.1:27017").and_return(server) cluster.should_receive(:sync_server).with(server).and_return([]) cluster.sync 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 write(*args) raise Errors::ConnectionFailure, "Socket connection was closed by remote host" unless alive? super 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.open(path_or_url, ext = nil, options = {}) options, ext = ext, nil if ext.is_a?(Hash) ext ||= if File.exist?(path_or_url) File.extname(path_or_url) else File.extname(URI(path_or_url).path) end ext.sub!(/:.*/, '') # hack for filenames or URLs that include a colon Kernel.open(path_or_url, "rb", options) do |file| read(file, ext) end end
0
Ruby
CWE-78
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/78.html
vulnerable
def drop_file Log.add_info(request, '') # Not to show passwords. return unless request.post? if params[:file].nil? or params[:file].size <= 0 render(:text => '') return end my_folder = @login_user.get_my_folder if my_folder.nil? render(:text => 'ERROR:' + t('folder.cannot_find_my_folder')) return end original_filename = params[:file].original_filename title = ApplicationHelper.take_ncols(File.basename(original_filename, '.*'), 60, nil) item = Item.new_info(my_folder.id) item.title = title item.user_id = @login_user.id item.save! params[:title] ||= title attachment = Attachment.create(params, item, 0) toy = Toy.new toy.user_id = @login_user.id toy.xtype = Toy::XTYPE_ITEM toy.target_id = item.id toy.x, toy.y = DesktopsHelper.find_empty_block(@login_user) toy.save! render(:text => t('file.uploaded')) 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 remove_all_persons check_write_access! self.package_user_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
def resource_master(params, request, session) if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end unless params[:resource_id] return [400, 'resource_id has to be specified.'] end _, stderr, retval = run_cmd( session, PCS, 'resource', 'master', params[:resource_id] ) if retval != 0 return [400, 'Unable to create master/slave resource from ' + "'#{params[:resource_id]}': #{stderr.join('')}" ] end return 200 end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def get_group_users Log.add_info(request, params.inspect) @group_id = nil if !params[:thetisBoxSelKeeper].nil? @group_id = params[:thetisBoxSelKeeper].split(':').last elsif !params[:group_id].nil? and !params[:group_id].empty? @group_id = params[:group_id] end submit_url = url_for(:controller => 'schedules', :action => 'get_group_users') render(:partial => 'common/select_users', :layout => false, :locals => {:target_attr => :id, :submit_url => submit_url}) 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 exclude_from_group Log.add_info(request, params.inspect) if params[:group_id].nil? or params[:group_id].empty? render(:partial => 'ajax_groups', :layout => false) return end group_id = params[:group_id] begin @user = User.find(params[:id]) unless @user.nil? if @user.exclude_from(group_id) @user.save if @user.id == @login_user.id @login_user = @user end end end rescue => evar Log.add_error(request, evar) end render(:partial => 'ajax_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 check_action_permission!(skip_source = nil) super(skip_source) # only perform the following check, if we are called from # BsRequest.permission_check_change_state! (that is, if # skip_source is set to true). Always executing this check # would be a regression, because this code is also executed # if a new request is created (which could fail if User.current # cannot modify the source_package). return unless skip_source target_project = Project.get_by_name(self.target_project) return unless target_project && target_project.is_a?(Project) target_package = target_project.packages.find_by_name(self.target_package) initialize_devel_package = target_project.find_attribute('OBS', 'InitializeDevelPackage') return if target_package || !initialize_devel_package source_package = Package.get_by_project_and_name(source_project, self.source_package) return if !source_package || User.current.can_modify?(source_package) msg = 'No permission to initialize the source package as a devel package' raise PostRequestNoPermission, msg end
0
Ruby
CWE-732
Incorrect Permission Assignment for Critical Resource
The product specifies permissions for a security-critical resource in a way that allows that resource to be read or modified by unintended actors.
https://cwe.mitre.org/data/definitions/732.html
vulnerable
def initialize(file, name) @file = file @name = name 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 self.prepare_rdoc root debug, verbose = false, false prepare_script = Pathname.new(Rails.root) + "script/rdoc_prepare_script.rb" if prepare_script.executable? dirs = Environment.puppetEnvs.values.join(":").split(":").uniq.sort.join(" ") puts "Running #{prepare_script} #{dirs}" if debug location = %x{#{prepare_script} #{dirs}} if $? == 0 root = location.chomp puts "Relocated modules to #{root}" if verbose end else puts "No executable #{prepare_script} found so using the uncopied module sources" if verbose end root end def as_json(options={}) super({:only => [:name, :id], :include => [:lookup_keys]}) end def self.search_by_host(key, operator, value) conditions = sanitize_sql_for_conditions(["hosts.name #{operator} ?", value_to_sql(operator, value)]) direct = Puppetclass.joins(:hosts).where(conditions).select('puppetclasses.id').map(&:id).uniq hostgroup = Hostgroup.joins(:hosts).where(conditions).first indirect = HostgroupClass.where(:hostgroup_id => hostgroup.path_ids).pluck(:puppetclass_id).uniq return { :conditions => "1=0" } if direct.blank? && indirect.blank? puppet_classes = (direct + indirect).uniq { :conditions => "puppetclasses.id IN(#{puppet_classes.join(',')})" } end def self.value_to_sql(operator, value) return value if operator !~ /LIKE/i return value.tr_s('%*', '%') if (value ~ /%|\*/) return "%#{value}%" 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 from_time(time) from_data @@generator.generate(time.to_i) end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def test_should_allow_anchors assert_sanitized %(<a href="foo" onclick="bar"><script>baz</script></a>), %(<a href=\"foo\"></a>) end def test_video_poster_sanitization assert_sanitized %(<video src="videofile.ogg" autoplay poster="posterimage.jpg"></video>), %(<video src="videofile.ogg" poster="posterimage.jpg"></video>) assert_sanitized %(<video src="videofile.ogg" poster=javascript:alert(1)></video>), %(<video src="videofile.ogg"></video>) end # RFC 3986, sec 4.2 def test_allow_colons_in_path_component assert_sanitized "<a href=\"./this:that\">foo</a>" 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 "delegates to the current database" do database = mock(Moped::Database) session.should_receive(:current_database).and_return(database) database.should_receive(:drop) session.drop 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 split_header self.fields = raw_source.split(HEADER_SPLIT) end
1
Ruby
CWE-93
Improper Neutralization of CRLF Sequences ('CRLF Injection')
The software uses CRLF (carriage return line feeds) as a special element, e.g. to separate lines or records, but it does not neutralize or incorrectly neutralizes CRLF sequences from inputs.
https://cwe.mitre.org/data/definitions/93.html
safe
it "stores the collection" do query.collection.should eq collection 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 "handles Symbol keys" do cl = subject.build("true", :abc => "def") expect(cl).to eq "true --abc def" 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 self.find_term(user_id, start_date, end_date) SqlHelper.validate_token([user_id]) start_s = start_date.strftime(Schedule::SYS_DATE_FORM) end_s = end_date.strftime(Schedule::SYS_DATE_FORM) con = "(user_id=#{user_id.to_i}) and (date >= '#{start_s}') and (date <= '#{end_s}')" ary = Timecard.where(con).order('date ASC').to_a timecards_h = Hash.new unless ary.nil? ary.each do |timecard| timecards_h[timecard.date.strftime(Schedule::SYS_DATE_FORM)] = timecard end end return timecards_h end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def update_titles_order Log.add_info(request, params.inspect) return unless request.post? titles = params[:titles_order] org_order = User.get_config_titles org_order = [] if org_order.nil? User.save_config_titles(titles) idx = 0 titles.each do |title| if title != org_order[idx] User.update_xorder(title, idx) end idx += 1 end render(:text => '') end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def with_secondary(retry_on_failure = true, &block) available_nodes = nodes.shuffle!.partition(&:secondary?).flatten while node = available_nodes.shift begin return yield node.apply_auth(auth) rescue Errors::ConnectionFailure # That node's no good, so let's try the next one. next 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 log_operations(logger, ops, duration) prefix = " MOPED: #{address} " indent = " "*prefix.length runtime = (" (%.1fms)" % duration) if ops.length == 1 logger.debug prefix + ops.first.log_inspect + runtime else first, *middle, last = ops logger.debug prefix + first.log_inspect middle.each { |m| logger.debug indent + m.log_inspect } logger.debug indent + last.log_inspect + runtime end end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def self.count_ack_users(item_id) SqlHelper.validate_token([item_id]) return Comment.where("(item_id=#{item_id.to_i}) and (xtype='#{Comment::XTYPE_DIST_ACK}')").count 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.reminders(options={}) days = options[:days] || 7 project = options[:project] ? Project.find(options[:project]) : nil tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil target_version_id = options[:version] ? Version.named(options[:version]).pluck(:id) : nil if options[:version] && target_version_id.blank? raise ActiveRecord::RecordNotFound.new("Couldn't find Version with named #{options[:version]}") end user_ids = options[:users] scope = Issue.open.where("#{Issue.table_name}.assigned_to_id IS NOT NULL" + " AND #{Project.table_name}.status = #{Project::STATUS_ACTIVE}" + " AND #{Issue.table_name}.due_date <= ?", days.day.from_now.to_date ) scope = scope.where(:assigned_to_id => user_ids) if user_ids.present? scope = scope.where(:project_id => project.id) if project scope = scope.where(:fixed_version_id => target_version_id) if target_version_id.present? scope = scope.where(:tracker_id => tracker.id) if tracker issues_by_assignee = scope.includes(:status, :assigned_to, :project, :tracker). group_by(&:assigned_to) issues_by_assignee.keys.each do |assignee| if assignee.is_a?(Group) assignee.users.each do |user| issues_by_assignee[user] ||= [] issues_by_assignee[user] += issues_by_assignee[assignee] end end end issues_by_assignee.each do |assignee, issues| reminder(assignee, issues, days).deliver if assignee.is_a?(User) && assignee.active? end end
0
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
vulnerable
def approve_account_if_needed if invited_user.present? && reviewable_user = ReviewableUser.find_by(target: invited_user, status: Reviewable.statuses[:pending]) reviewable_user.perform( invite.invited_by, :approve_user, send_email: false, approved_by_invite: true ) end 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 limited? @limited 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
detectMimeType(filename) { if (!filename) { return defaultMimeType; } let parsed = path.parse(filename); let extension = (parsed.ext.substr(1) || parsed.name || '') .split('?') .shift() .trim() .toLowerCase(); let value = defaultMimeType; if (extensions.has(extension)) { value = extensions.get(extension); } if (Array.isArray(value)) { return value[0]; } return value; },
0
Ruby
CWE-88
Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')
The software constructs a string for a command to executed by a separate component in another control sphere, but it does not properly delimit the intended arguments, options, or switches within that command string.
https://cwe.mitre.org/data/definitions/88.html
vulnerable
def remove_acl_remote(params, request, session) if not allowed_for_local_cluster(session, Permissions::GRANT) return 403, 'Permission denied' end if params["item"] == "permission" retval = remove_acl_permission(session, params["acl_perm_id"]) elsif params["item"] == "usergroup" retval = remove_acl_usergroup( session, params["role_id"],params["usergroup_id"] ) else retval = "Error: Unknown removal request" end if retval == "" return [200, "Successfully removed permission from role"] else return [400, retval] 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 session.with(consistency: :strong) do |session| session.context.remove operation.database, operation.collection, operation.selector, flags: [:remove_first] end end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def self.get_for(group_id, include_parents=false, enabled=nil) SqlHelper.validate_token([group_id]) con = [] #con << "(disabled=#{!enabled})" unless enabled.nil? if include_parents group_con = '(group_id is null)' unless group_id.nil? or group_id.to_s == '0' group_obj_cache = {} group = Group.find_with_cache(group_id, group_obj_cache) group_ids = group.get_parents(false, group_obj_cache) group_ids << group_id group_con << " or (group_id in (#{group_ids.join(',')}))" end con << '(' + group_con + ')' else con << "(group_id=#{group_id})" end order_by = 'order by xorder ASC, id ASC' #order_by = 'order by disabled ASC, xorder ASC, id ASC' sql = 'select * from official_titles where ' + con.join(' and ') + ' ' + order_by return OfficialTitle.find_by_sql(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
it 'supports group' do topic = Fabricate(:topic, created_at: 3.months.ago) post = Fabricate(:post, raw: 'hi this is a test 123 123', topic: topic) group = Group.create!(name: "Like_a_Boss") GroupUser.create!(user_id: post.user_id, group_id: group.id) expect(Search.execute('group:like_a_boss').posts.length).to eq(1) expect(Search.execute('group:"like a brick"').posts.length).to eq(0) 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 test_should_sanitize_with_trailing_space raw = "display:block; " expected = "display: block;" assert_equal expected, sanitize_css(raw) 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 current_user User.except_hidden.find_by_login(self.user) 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 Log.add_info(request, params.inspect) return unless request.post? SqlHelper.validate_token([params[:groups], params[:teams]]) if params[:groups].blank? params[:equipment][:groups] = nil else params[:equipment][:groups] = '|' + params[:groups].join('|') + '|' end if params[:teams].blank? params[:equipment][:teams] = nil else params[:equipment][:teams] = '|' + params[:teams].join('|') + '|' end @equipment = Equipment.new(params.require(:equipment).permit(Equipment::PERMIT_BASE)) begin @equipment.save! rescue => evar Log.add_error(request, evar) render(:controller => 'equipment', :action => 'edit') return end flash[:notice] = t('msg.register_success') 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
it "creates an index" do indexes.create(key, background: true) indexes[key]["background"].should eq true end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def process_cors(env) resource, error = match_resource(env) if resource Result.hit(env) cors = resource.to_headers(env) cors else Result.miss(env, error) nil end 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