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 get_mail_attachments Log.add_info(request, params.inspect) email_id = params[:id] email = Email.find(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_attachmen...
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_string(string) raise Errors::InvalidObjectId.new(string) unless legal?(string) data = [] 12.times { |i| data << string[i*2, 2].to_i(16) } new data 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 "yields all documents in the cursor" do cursor = Moped::Cursor.allocate cursor.stub(:to_enum).and_return([1, 2].to_enum) Moped::Cursor.stub(new: cursor) query.to_a.should eq [1, 2] 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.from_yaml(input) Gem.load_yaml input = normalize_yaml_input input spec = YAML.load input if spec && spec.class == FalseClass then raise Gem::EndOfYAMLException end unless Gem::Specification === spec then raise Gem::Exception, "YAML data doesn't evaluate to gem specifica...
0
Ruby
CWE-502
Deserialization of Untrusted Data
The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
it "returns the document" do session.simple_query(query).should eq(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
it "changes the fields returned" do users.insert(documents) users.find(scope: scope).select(_id: 0).to_a.should eq documents end
1
Ruby
CWE-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 destroy_local Log.add_info(request, params.inspect) return unless request.post? begin Item.find(params[:id]).destroy rescue end # Get $Templates and its sub folders to update partial division. @tmpl_folder, @tmpl_local_folder = TemplatesHelper.get_tmpl_subfolder(TemplatesHelpe...
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 check_owner return if (params[:id].blank? or @login_user.nil?) mail_filter = MailFilter.find(params[:id]) if !@login_user.admin?(User::AUTH_MAIL) and mail_filter.mail_account.user_id != @login_user.id Log.add_check(request, '[check_owner]'+request.to_s) flash[:notice] = t('msg.need_to_...
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it "drops the collection" do result = session[:users].drop result["ns"].should eq "moped_test.users" 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 sanitize_string(host) if host.start_with?(".") /\A([a-z0-9-]+\.)?#{Regexp.escape(host[1..-1])}\z/i else /\A#{Regexp.escape host}\z/i end end
1
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
safe
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-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def self.destroy_by_user(user_id, add_con=nil) SqlHelper.validate_token([user_id]) con = "user_id=#{user_id}" con << " and (#{add_con})" unless add_con.nil? or add_con.empty? mail_accounts = MailAccount.where(con).to_a mail_accounts.each do |mail_account| mail_account.destroy end en...
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 create_q_page Log.add_info(request, params.inspect) return unless request.post? @tmpl_folder, @tmpl_q_folder = TemplatesHelper.get_tmpl_subfolder(TemplatesHelper::TMPL_RESEARCH) unless @tmpl_q_folder.nil? @items = Folder.get_items_admin(@tmpl_q_folder.id, 'xorder ASC') if !@items....
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 "recognizes and generates #destroy" do { :delete => "/users/1" }.should route_to(:controller => "users", :action => "destroy", :id => "1") 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 exists = true if params.has_key?(:inflated_object) params[:name] ||= params[:inflated_object].name params[:admin] ||= params[:inflated_object].admin end # We can only create clients if we're the admin or the validator. # But only allow creating admin clients if we're alrea...
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 call(exception, locale, key, options) if exception.is_a?(MissingTranslation) # # TODO: this block is to be replaced by `exception.message` when # rescue_format is removed if options[:rescue_format] == :html if @rescue_format_deprecation ...
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 read_config(self, config, **kwargs): self.recaptcha_private_key = config.get("recaptcha_private_key") self.recaptcha_public_key = config.get("recaptcha_public_key") self.enable_registration_captcha = config.get( "enable_registration_captcha", False ) self.reca...
0
Ruby
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/74.html
vulnerable
def check_owner return if (params[:id].nil? or params[:id].empty? or @login_user.nil?) mail_filter = MailFilter.find(params[:id]) if !@login_user.admin?(User::AUTH_MAIL) and mail_filter.mail_account.user_id != @login_user.id Log.add_check(request, '[check_owner]'+request.to_s) flash[:notic...
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 a second factor prompt' do get "/session/email-login/#{email_token.token}" expect(response.status).to eq(200) response_body = CGI.unescapeHTML(response.body) expect(response_body).to include(I18n.t( "login.second_factor_title" ...
0
Ruby
CWE-287
Improper Authentication
When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.
https://cwe.mitre.org/data/definitions/287.html
vulnerable
def self.connect(host, port, timeout) Timeout::timeout(timeout) do new(host, port).tap do |sock| sock.set_encoding 'binary' 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 spoofed? if has_name? && has_extension? && media_type_mismatch? && mapping_override_mismatch? Paperclip.log("Content Type Spoof: Filename #{File.basename(@name)} (#{supplied_content_type} from Headers, #{content_types_from_name} from Extension), content type discovered from file command: #{calcula...
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 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["...
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def set_node_utilization(params, reqest, session) unless allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end unless params[:node] and params[:name] return 400, 'node and name are required' end node = params[:node] name = params[:name] value = params[:value]...
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 ensure_primary Threaded.begin :ensure_primary yield ensure Threaded.end :ensure_primary
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def update_map Log.add_info(request, params.inspect) return unless request.post? group_id = params[:group_id] SqlHelper.validate_token([group_id]) @office_map = OfficeMap.get_for_group(group_id, true) params[:office_map].delete(:group_id) @office_map.update_attributes(params.require(:...
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_nest get :nest, {:id => hostgroups(:common).id}, set_session_user assert_template 'new' 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 "inserts a single document" do document = { "_id" => Moped::BSON::ObjectId.new, "scope" => scope } session[:users].insert(document) session[:users].find(document).one.should eq document end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
it "should return :file if the URI protocol is set to 'file'" do @request.expects(:protocol).returns "file" @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 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 ')+...
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def get_folders_order Log.add_info(request, params.inspect) @folder_id = params[:id] SqlHelper.validate_token([@folder_id]) if @folder_id == '0' @folders = MailFolder.get_account_roots_for(@login_user) else mail_folder = MailFolder.find(@folder_id) if mail_folder.user_id == @lo...
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 generate(type, str) case type when :md5 attribute_value = '{MD5}' + Base64.encode64(Digest::MD5.digest(str)).chomp! when :sha attribute_value = '{SHA}' + Base64.encode64(Digest::SHA1.digest(str)).chomp! when :ssha srand; salt = SecureRandom.random_bytes(16) ...
1
Ruby
CWE-916
Use of Password Hash With Insufficient Computational Effort
The software generates a hash for a password, but it uses a scheme that does not provide a sufficient level of computational effort that would make password cracking attacks infeasible or expensive.
https://cwe.mitre.org/data/definitions/916.html
safe
it "returns an enumerator" do cursor = mock(Moped::Cursor) Moped::Cursor.stub(new: cursor) query.each.should be_a Enumerator 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 redirect_url return "/" unless member_login_node member_login_node.redirect_url || "/" 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 remote_node_available(params, request, session) if (not ISRHEL6 and File.exist?(Cfgsync::CorosyncConf.file_path)) or (ISRHEL6 and File.exist?(Cfgsync::ClusterConf.file_path)) or File.exist?("/var/lib/pacemaker/cib/cib.xml") return JSON.generate({:node_available => false}) end return JSON.generate({:node_a...
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 "removes all matching documents" do session.should_receive(:with, :consistency => :strong). and_yield(session) session.should_receive(:execute).with do |delete| delete.flags.should eq [] delete.selector.should eq query.operation.selector end query.remove_all ...
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 "drops the current database" do session.with(database: "moped_test_2") do |session| session.drop.should eq("dropped" => "moped_test_2", "ok" => 1) 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 auth_seeds [ENV["MONGOHQ_SINGLE_URL"]] 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_using_size(mail_account_id, add_con=nil) SqlHelper.validate_token([mail_account_id]) con = [] con << "(mail_account_id=#{mail_account_id.to_i})" con << "(#{add_con})" unless add_con.nil? or add_con.empty? return (Email.count_by_sql("select SUM(size) from emails where #{con.join(' a...
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_login raise Discourse::NotFound if !SiteSetting.enable_local_logins_via_email second_factor_token = params[:second_factor_token] second_factor_method = params[:second_factor_method].to_i token = params[:token] valid_token = !!EmailToken.valid_token_format?(token) user = EmailToken.co...
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
it "should choose :rest when a server is specified" do @request.stubs(:protocol).returns "puppet" @request.expects(:server).returns "foo" @object.select(@request).should == :rest 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 check_owner return if (params[:id].blank? or @login_user.nil?) address = Address.find(params[:id]) if !@login_user.admin?(User::AUTH_ADDRESSBOOK) and address.owner_id != @login_user.id Log.add_check(request, '[check_owner]'+request.to_s) flash[:notice] = t('msg.need_to_be_owner') ...
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 down? @down_at end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def set_project_type(project_type_name) check_write_access! mytype = DbProjectType.find_by_name(project_type_name) return false unless mytype self.type_id = mytype.id self.save! return true end
1
Ruby
CWE-275
Permission Issues
Weaknesses in this category are related to improper assignment or handling of permissions.
https://cwe.mitre.org/data/definitions/275.html
safe
it "sets the current database" do session.should_receive(:set_current_database).with(:admin) session.use :admin 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 sanitize_key(key) case key when Symbol then "--#{key.to_s.tr("_", "-")}" else key 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 end(name) stack(name).pop 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 send_local_configs_to_nodes( session, nodes, force=false, clear_local_permissions=false ) configs = Cfgsync::get_configs_local(true) if clear_local_permissions pcs_config = PCSConfig.new(configs[Cfgsync::PcsdSettings.name].text()) pcs_config.permissions_local = Permissions::PermissionsSet.new([]) ...
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 redirect_back_or_default(default, options={}) back_url = params[:back_url].to_s if back_url.present? begin uri = URI.parse(back_url) # do not redirect user to another host or to the login or register page if (uri.relative? || (uri.host == request.host)) && !uri.path.match(%r{...
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], ...
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def remove_acl_permission(session, acl_perm_id) stdout, stderror, retval = run_cmd( session, PCS, "acl", "permission", "delete", acl_perm_id.to_s ) if retval != 0 if stderror.empty? return "Error removing 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
it "removes the first matching document" do users.insert(documents) users.find(scope: scope).remove users.find(scope: scope).count.should eq 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 "memoizes the database" do database = session.current_database session.current_database.should equal(database) end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def verify_signature(string, signature) if signature.nil? fail InvalidSignature, "missing \"signature\" param" elsif signature != generate_signature(string) fail InvalidSignature, "provided signature does not match the calculated signature" end end
0
Ruby
CWE-208
Observable Timing Discrepancy
Two separate operations in a product require different amounts of time to complete, in a way that is observable to an actor and reveals security-relevant information about the state of the product, such as whether a particular operation was successful or not.
https://cwe.mitre.org/data/definitions/208.html
vulnerable
def remove_constraint_remote(params, request, session) if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end if params[:constraint_id] retval = remove_constraint(session, params[:constraint_id]) if retval == 0 return "Constraint #{params[:constraint_id...
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 setup FactoryGirl.create(:host, :location => nil) 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 render_notification(notification) uniqueid = notification[:uniqueid] data = convert_to_hash(notification[:data]) # In case data[:name] is invalid data[:email] = User.find(data[:user_id]).email case data[:type] when /comment/ then comment_link(uniqueid, data) when /accepted_ally_request...
0
Ruby
NVD-CWE-Other
Other
NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
https://nvd.nist.gov/vuln/categories
vulnerable
def process # We don't want any tracking back in the fs. Unlikely, but there # you go. if host =~ Regexp.union(/[#{SEPARATOR}]/, /\A\.\.?\Z/) raise ArgumentError, "Invalid node name #{host.inspect}" end dir = File.join(Puppet[:reportdir], host) if ! FileTest.exists?(dir) FileUti...
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 t...
https://cwe.mitre.org/data/definitions/22.html
safe
def get_project_application(item_id) SqlHelper.validate_token([item_id]) con = "(item_id=#{item_id}) and (user_id=#{self.id}) and (xtype='#{Comment::XTYPE_APPLY}')" begin comment = Comment.where(con).first rescue 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 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_fo...
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 remote_pcsd_restart(params, request, session) pcsd_restart() return [200, 'success'] 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 "returns an enumerator" do cursor = mock(Moped::Cursor) Moped::Cursor.stub(new: cursor) query.each.should be_a Enumerator 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 drop_on_exit Log.add_info(request, params.inspect) return unless request.post? SqlHelper.validate_token([params[:id]]) unless @login_user.nil? Location.destroy(params[:id]) end render(:text => params[:id]) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def destroy Log.add_info(request, params.inspect) return unless request.post? if params[:check_filter].nil? list render(:action => 'list', :layout => !request.xhr?) return end count = 0 params[:check_filter].each do |filter_id, value| if value == '1' begin ...
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) SqlHelper.validate_token([user_id]) return Research.where("user_id=#{user_id.to_i}").first end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def insert(database, collection, documents) process Protocol::Insert.new(database, collection, documents) end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def _marshal(val, options) yield marshal?(options) ? Marshal.dump(val) : val 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 set_sync_options(params, request, session) if not allowed_for_local_cluster(session, Permissions::FULL) return 403, 'Permission denied' end options = [ 'sync_thread_pause', 'sync_thread_resume', 'sync_thread_disable', 'sync_thread_enable', ] if params.keys.count { |key| options.include?(key) ...
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 week 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 params[:display] = 'week' end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def update(database, collection, selector, change, options = {}) with_node do |node| if safe? node.pipeline do node.update(database, collection, selector, change, options) node.command("admin", { getlasterror: 1 }.merge(safety)) end e...
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 add_acl_role(session, name, description) cmd = [PCS, "acl", "role", "create", name.to_s] if description.to_s != "" cmd << "description=#{description.to_s}" end stdout, stderror, retval = run_cmd(session, *cmd) if retval != 0 return stderror.join("\n").strip 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 self.save_sync_new_version(config, nodes, cluster_name, fetch_on_conflict, tokens={}) if not cluster_name or cluster_name.empty? # we run on a standalone host, no config syncing config.version += 1 config.save() return true, {} else # we run in a cluster so we need to sync th...
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 simple_query(query) query.limit = -1 query(query).documents.first 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 destroy Log.add_info(request, params.inspect) return unless request.post? begin Item.destroy(params[:id]) rescue => evar Log.add_error(request, evar) end if params[:from_action].nil? render(:text => params[:id]) else flash[:notice] = t('msg.delete_success') ...
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_update_invalid put :update, {:id => Hostgroup.first, :hostgroup => { :name => '' }}, set_session_user assert_template 'edit' 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 cluster_enable(params, request, session) if params[:name] code, response = send_request_with_token( session, params[:name], 'cluster_enable', true ) else if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end success = enable_cluster(ses...
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 copy Log.add_info(request, params.inspect) return unless request.post? tmpl_id = params[:thetisBoxSelKeeper].split(':').last tmpl_item = Item.find(tmpl_id) item = tmpl_item.copy(@login_user.id, @login_user.get_my_folder.id) if item.public != false item.update_attribute(:public, fa...
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 escape_for_shell(str) # An empty argument will be skipped, so return empty quotes. return "''" if str.empty? str = str.dup # Process as a single byte sequence because not all shell # implementations are multibyte aware. str.gsub!(/([^A-Za-z0-9_\s\+\-.,:\/@\n])/n, "\\\\\\1")...
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
it "should reject a wildcard subject" do @request.content.stubs(:subject). returns(OpenSSL::X509::Name.new([["CN", "*.local"]])) expect { @ca.sign(@name) }.to raise_error( Puppet::SSL::CertificateAuthority::CertificateSigningError, /subject contains a wildcard/ ...
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 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}) and (date >= '#{start_s}') and (date <= '#{end_s}')" ary = Timecard.where(c...
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 escape evil haxxor attemptes" do Mail.defaults do delivery_method :exim, :arguments => nil end mail = Mail.new do from '"foo\";touch /tmp/PWNED;\""@blah.com' to 'marcel@test.lindsaar.net' subject 'invalid RFC2822' end Mail::Exim.should_receive(:...
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 kill_cursors(cursor_ids) process Protocol::KillCursors.new(cursor_ids) 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 logout(database) command = Protocol::Command.new(database, logout: 1) connection.write [command] result = connection.read.documents.first raise Errors::OperationFailure.new(command, result) unless result["ok"] == 1 auth.delete(database) 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 activity_user user = current_user.pref[:activity_user] if user && user != "all_users" user = if user =~ /@/ # email User.where(:email => user).first else # first_name middle_name last_name any_name name_query = if user.include?(" ") user.name_permutations.map{...
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 calculated_type_mismatch? !media_types_from_name.include?(calculated_media_type) end
1
Ruby
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
def cluster_status_gui(session, cluster_name, dont_update_config=false) cluster_nodes = get_cluster_nodes(cluster_name) status = cluster_status_from_nodes(session, cluster_nodes, cluster_name) unless status return 403, 'Permission denied' end new_cluster_nodes = [] new_cluster_nodes += status[:corosync...
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) SqlHelper.validate_token([params[:id]]) begin @folder = Folder.find(params[:id]) rescue => evar Log.add_error(request, evar) end @group_id = nil if !params[:thetisBoxSelKeeper].nil? @group_id = params[:thetisBoxS...
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_condtions_for(user, mail_account_ids) SqlHelper.validate_token([mail_account_ids]) if mail_account_ids.nil? or mail_account_ids.empty? return "(user_id=#{user.id} and (mail_account_id is null))" else return "(user_id=#{user.id} and (mail_account_id is null or mail_account_id in ...
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 build_query(path, details) query = @pattern.dup prefix = path.prefix.empty? ? "" : "#{escape_entry(path.prefix)}\\1" query.gsub!(/\:prefix(\/)?/, prefix) partial = escape_entry(path.partial? ? "_#{path.name}" : path.name) query.gsub!(/\:action/, partial) details.each do |e...
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_next_revision(user_id, source_id) copied_items = Item.where("user_id=#{user_id} and source_id=#{source_id}").order('created_at DESC').to_a rev = 0 copied_items.each do |item| rev_ary = item.title.scan(/[#](\d\d\d)$/) next if rev_ary.nil? rev = rev_ary.first.to_a.first.to_i...
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 write(operations) buf = "" operations.each do |operation| operation.request_id = (@request_id += 1) operation.serialize(buf) end @sock.write buf 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 'is possible to return errors in jsonapi format' do get '/' expect(last_response.body).to eq('{"error":"rain!"}') 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 "with dofollowify enabled, links should be nofollowed" do @blog.dofollowify = true @blog.save expect(nofollowify_links('<a href="http://myblog.net">my blog</a>')). to eq('<a href="http://myblog.net">my blog</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 "sanitizes Fixnum array param value" do cl = subject.build("true", nil => [1]) expect(cl).to eq "true 1" end
1
Ruby
CWE-78
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/78.html
safe
it 'should return the right response' do email_token.update!(created_at: 999.years.ago) get "/session/email-login/#{email_token.token}" expect(response.status).to eq(200) expect(CGI.unescapeHTML(response.body)).to match( I18n.t('email_login.invalid_token') ...
0
Ruby
CWE-287
Improper Authentication
When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.
https://cwe.mitre.org/data/definitions/287.html
vulnerable
def email_login raise Discourse::NotFound if !SiteSetting.enable_local_logins_via_email second_factor_token = params[:second_factor_token] second_factor_method = params[:second_factor_method].to_i token = params[:token] valid_token = !!EmailToken.valid_token_format?(token) user = EmailToken.co...
0
Ruby
CWE-287
Improper Authentication
When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.
https://cwe.mitre.org/data/definitions/287.html
vulnerable
def actions if params[:media_action] != 'crop_url' authorize! :manage, :media end params[:folder] = params[:folder].gsub("//", "/") if params[:folder].present? case params[:media_action] when "new_folder" params[:folder] = slugify_folder(params[:folder]) render partial: "re...
0
Ruby
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
def cluster_destroy(params, request, session) if not allowed_for_local_cluster(session, Permissions::FULL) return 403, 'Permission denied' end out, errout, retval = run_cmd(session, PCS, "cluster", "destroy") if retval == 0 return [200, "Successfully destroyed cluster"] else return [400, "Error de...
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 do_project_copy( params ) # set user if nil, needed for delayed job in Package model User.current ||= User.find_by_login(params[:user]) check_write_access! # copy entire project in the backend begin path = "/source/#{URI.escape(self.name)}" path << Suse::Backend.build_query_from_...
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 with_primary(retry_on_failure = true, &block) if node = nodes.find(&:primary?) begin node.ensure_primary do return yield node.apply_auth(auth) end rescue Errors::ConnectionFailure, Errors::ReplicaSetReconfigured # Fall through to the code below if ...
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 call(exception, locale, key, options) if exception.is_a?(MissingTranslation) options[:rescue_format] == :html ? exception.html_message : exception.message elsif exception.is_a?(Exception) raise exception else throw :exception, exception end e...
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