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 show_tree if params[:action] == 'show_tree' Log.add_info(request, params.inspect) end con = [] con << "(user_id=#{@login_user.id})" account_xtype = params[:mail_account_xtype] unless account_xtype.blank? SqlHelper.validate_token([account_xtype]) con << "(xtype='#{accou...
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_write_access! return if Rails.env.test? and User.current.nil? # for unit tests # the can_create_check is inconsistent with package class check_write_access! check unless User.current.can_modify_project?(self) || User.current.can_create_project?(self.name) raise WritePermissionError, "No p...
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 initialize(name, value = nil, charset = 'utf-8') case when name =~ /:/ # Field.new("field-name: field data") @charset = value.blank? ? charset : value @name, @value = split(name) when name !~ /:/ && value.blank? # Field.new("field-name") @name = name ...
0
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
vulnerable
it "allows you to create an account and redeems the invite successfully even if must_approve_users is enabled" do SiteSetting.must_approve_users = true login_with_sso_and_invite expect(response.status).to eq(302) expect(response).to redirect_to("/") expect(invite.reload.r...
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 auth_credentials [ENV["MONGOHQ_SINGLE_USER"], ENV["MONGOHQ_SINGLE_PASS"]] 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 "updates the record matching selector with change" do session.should_receive(:with, :consistency => :strong). and_yield(session) session.should_receive(:execute).with do |update| update.flags.should eq [] update.selector.should eq query.operation.selector update.updat...
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def self.get_for(user_id, date_s) SqlHelper.validate_token([user_id, date_s]) begin con = "(user_id=#{user_id}) and (date='#{date_s}')" return Timecard.where(con).first rescue end return nil end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def test_post uri = URI('http://localhost:6470/makeme') req = Net::HTTP::Post.new(uri) # Set the headers the way we want them. req['Accept-Encoding'] = '*' req['Accept'] = 'application/json' req['User-Agent'] = 'Ruby' res = Net::HTTP.start(uri.hostname, uri.port) { |h| h.request...
0
Ruby
CWE-444
Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')
The product acts as an intermediary HTTP agent (such as a proxy or firewall) in the data flow between two entities such as a client and server, but it does not interpret malformed HTTP requests or responses in ways that are consistent with how the messages will be processed by ...
https://cwe.mitre.org/data/definitions/444.html
vulnerable
def build_command_line(command, params = nil) CommandLineBuilder.new.build(command, params) 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 update_patchinfo(patchinfo, opts = {}) check_write_access! opts[:enfore_issue_update] ||= false # collect bugnumbers from diff self.packages.each do |p| # create diff per package next if p.package_kinds.find_by_kind 'patchinfo' p.package_issues.each do |i| if i.change ...
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 handle_unverified_request super raise ActionController::InvalidAuthenticityToken end
1
Ruby
CWE-352
Cross-Site Request Forgery (CSRF)
The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.
https://cwe.mitre.org/data/definitions/352.html
safe
def primaries servers.select(&:primary?) 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 "merges the old and new session's options" do session.with(new_options) do |new_session| new_session.options.should eq options.merge(new_options) end end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def test_update_valid Medium.any_instance.stubs(:valid?).returns(true) put :update, {:id => @model, :medium => {:name => "MyUpdatedMedia"}}, set_session_user assert_redirected_to media_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
it 'fails when local logins via email is disabled' do SiteSetting.enable_local_logins_via_email = false get "/session/email-login/#{email_token.token}" expect(response.status).to eq(404) end
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
def self.getSuperuserSession() return { :username => SUPERUSER, :usergroups => [], } 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 generate(time, counter = 0) process_thread_id = "#{Process.pid}#{Thread.current.object_id}".hash % 0xFFFF [ time, machine_id, process_thread_id, counter << 8 ].pack("N NX lXX NX") end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def create if params[:user] roles = params[:user].delete("spree_role_ids") end @user = Spree::User.new(params[:user]) if @user.save if roles @user.spree_roles = roles.reject(&:blank?).collect{|r| Spree::Role.find(r)} end flash....
1
Ruby
CWE-264
Permissions, Privileges, and Access Controls
Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.
https://cwe.mitre.org/data/definitions/264.html
safe
def self.validate_token(tokens, extra_chars=nil) extra_chars = Regexp.escape((extra_chars || []).join()) regexp = Regexp.new("^[ ]*[a-zA-Z0-9_.#{extra_chars}]+[ ]*$") [tokens].flatten.each do |token| next if token.blank? if token.to_s.match(regexp).nil? raise("[ERROR] SqlHelper.vali...
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 setup_user(operation, type = "", search = nil, user = :one) @one = users(user) as_admin do permission = Permission.find_by_name("#{operation}_#{type}") || FactoryGirl.create(:permission, :name => "#{operation}_#{type}") filter = FactoryGirl.build(:filter, :search => search) filter.permis...
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_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].blank? @group_id = params[:group_id] end SqlHelper.validate_token([@group_id]) submi...
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 index valid_http_methods :get, :post, :put # 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 para...
0
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
vulnerable
def test_execute_details_cleans_text spec_fetcher do |fetcher| fetcher.spec 'a', 2 do |s| s.summary = 'This is a lot of text. ' * 4 s.authors = ["Abraham Lincoln \u0001", "\u0002 Hirohito"] s.homepage = "http://a.example.com/\u0003" end fetcher.legacy_platform end ...
1
Ruby
CWE-94
Improper Control of Generation of Code ('Code Injection')
The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.
https://cwe.mitre.org/data/definitions/94.html
safe
def logout(database) auth.delete(database.to_s) 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 nodes_in_branch(branch, options={}) hg_args = ['rhlog', '--template', '{node}\n', '--rhbranch', CGI.escape(branch)] hg_args << '--from' << CGI.escape(branch) hg_args << '--to' << '0' hg_args << '--limit' << options[:limit] if options[:limit] hg(*hg_args) {...
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
def test_rcptto sock = FakeSocket.new smtp = Net::SMTP.new 'localhost', 25 smtp.instance_variable_set :@socket, sock assert smtp.rcptto("foo@example.com").success? assert_equal "RCPT TO:<foo@example.com>\r\n", sock.write_io.string end
1
Ruby
CWE-93
Improper Neutralization of CRLF Sequences ('CRLF Injection')
The software uses CRLF (carriage return line feeds) as a special element, e.g. to separate lines or records, but it does not neutralize or incorrectly neutralizes CRLF sequences from inputs.
https://cwe.mitre.org/data/definitions/93.html
safe
def __bson_load__(io) new io.read(12).unpack('C*') end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def self.get_for(user_id) SqlHelper.validate_token([user_id]) return Research.where("user_id=#{user_id}").first end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def test_execute_details_cleans_text spec_fetcher do |fetcher| fetcher.spec 'a', 2 do |s| s.summary = 'This is a lot of text. ' * 4 s.authors = ["Abraham Lincoln \u0001", "\u0002 Hirohito"] s.homepage = "http://a.example.com/\u0003" end fetcher.legacy_platform end ...
0
Ruby
CWE-94
Improper Control of Generation of Code ('Code Injection')
The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.
https://cwe.mitre.org/data/definitions/94.html
vulnerable
def set_description Log.add_info(request, params.inspect) return unless request.post? if params[:id].blank? @item = Item.new_info(0) @item.attributes = params.require(:item).permit(Item::PERMIT_BASE) @item.user_id = @login_user.id @item.title = t('paren.no_title') @item.sav...
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 annotate(path, identifier=nil) p = CGI.escape(scm_iconv(@path_encoding, 'UTF-8', path)) blame = Annotate.new hg 'rhannotate', '-ncu', '-r', CGI.escape(hgrev(identifier)), hgtarget(p) do |io| io.each_line do |line| line.force_encoding('ASCII-8BIT') ...
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
it 'returns json error' do subject.content_type :json, 'application/json' subject.default_error_formatter :json subject.get '/something' do 'foo' end get '/something' expect(last_response.status).to eq(406) expect(last_response.body).to eq("{\"error\":\"The requeste...
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 cama_current_user return @cama_current_user if defined?(@cama_current_user) # api current user... @cama_current_user = cama_calc_api_current_user return @cama_current_user if @cama_current_user return nil unless cookies[:auth_token].present? c = cookies[:auth_token].split("&") return ...
0
Ruby
CWE-613
Insufficient Session Expiration
According to WASC, "Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization."
https://cwe.mitre.org/data/definitions/613.html
vulnerable
def destroy_comment Log.add_info(request, params.inspect) return unless request.post? comment = Comment.find(params[:comment_id]) @item = comment.item unless @login_user.admin?(User::AUTH_ITEM) or \ comment.user_id == @login_user.id or \ @item.user_id == @login_user....
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 "raises a connection failure exception" do cluster.sync_server(server).should be_empty 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 add_order_set_constraint( session, resource_set_list, force=false, autocorrect=true ) command = [PCS, "constraint", "order"] resource_set_list.each { |resource_set| command << "set" command.concat(resource_set) } command << '--force' if force command << '--autocorrect' if autocorrect stdout, s...
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 test_should_sanitize_illegal_style_properties raw = %(display:block; position:absolute; left:0; top:0; width:100%; height:100%; z-index:1; background-color:black; background-image:url(http://www.ragingplatypus.com/i/cam-full.jpg); background-x:center; background-y:center; background-repeat:repeat;) 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
def replica_set_credentials [ENV["MONGOHQ_REPL_USER"], ENV["MONGOHQ_REPL_PASS"]] 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 Schema string_or_io Schema.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
it "includes plaintext secret" do expect(app.as_json).to include("secret" => "123123123") end
0
Ruby
CWE-862
Missing Authorization
The software does not perform an authorization check when an actor attempts to access a resource or perform an action.
https://cwe.mitre.org/data/definitions/862.html
vulnerable
def html_postprocess(_field, html) html 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 login(database, username, password) getnonce = Protocol::Command.new(database, getnonce: 1) connection.write [getnonce] result = connection.read.documents.first raise Errors::OperationFailure.new(getnonce, result) unless result["ok"] == 1 authenticate = Protocol::Commands::Authent...
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_update_valid AuthSourceLdap.any_instance.stubs(:valid?).returns(true) put :update, {:id => AuthSourceLdap.first, :auth_source_ldap => {:name => AuthSourceLdap.first.name} }, set_session_user assert_redirected_to auth_source_ldaps_url end
0
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
vulnerable
it "returns the number of matching document" do users.insert(documents) users.find(scope: scope).count.should eq 2 end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def query(database, collection, selector, options = {}) if consistency == :eventual options[:flags] ||= [] options[:flags] |= [:slave_ok] end with_node do |node| node.query(database, collection, selector, options) end end
1
Ruby
CWE-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 a new indexes instance" do collection.indexes.should be_an_instance_of Moped::Indexes 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 needs_refresh?(time) !@refreshed_at || @refreshed_at < time 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 write(operations) buf = "" operations.each do |operation| operation.request_id = (@request_id += 1) operation.serialize(buf) end @sock.write buf 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 reset Log.add_info(request, params.inspect) return unless request.post? Research.delete_all render(:text => '') rescue => evar Log.add_error(request, evar) render(:text => evar.to_s) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def login(database, username, password) cluster.auth[database.to_s] = [username, password] 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 empty Log.add_info(request, params.inspect) return unless request.post? @folder_id = params[:id] mail_account_id = params[:mail_account_id] SqlHelper.validate_token([@folder_id, mail_account_id]) trash_folder = MailFolder.get_for(@login_user, mail_account_id, MailFolder::XTYPE_TRASH) ...
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 next_client throw :shutdown if @shutdown begin servers = @servers.reject &:closed? clients = @clients.reject &:closed? Moped.logger.debug "replica_set: selecting on connections" readable, _, errors = Kernel.select(servers + clients, nil, clients, @time...
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def remove(database, collection, selector, options = {}) with_node do |node| if safe? node.pipeline do node.remove(database, collection, selector, options) node.command("admin", { getlasterror: 1 }.merge(safety)) end else ...
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 "connects and yields the primary node" do replica_set.with_primary do |node| node.address.should eq @primary.address end end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def set_admin User.current = users(:admin) end
1
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
safe
def refresh(nodes_to_refresh = @nodes) refreshed_nodes = [] seen = {} # Set up a recursive lambda function for refreshing a node and it's peers. refresh_node = ->(node) do return if seen[node] seen[node] = true # Add the node to the global list of known nodes. ...
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 bulk_unread_topic_ids topic_query = TopicQuery.new(current_user) if inbox = params[:private_message_inbox] filter = private_message_filter(topic_query, inbox) topic_query.options[:limit] = false topics = topic_query.filter_private_messages_unread(current_user, filter) else top...
0
Ruby
CWE-863
Incorrect Authorization
The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.
https://cwe.mitre.org/data/definitions/863.html
vulnerable
it "returns only published articles" do article = create(:article) create(:comment, article: article) unpublished_article = create(:article, state: "draft") create(:comment, article: unpublished_article) expect(described_class.published).to eq([article]) expect(described_class.be...
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 more? @get_more_op.cursor_id != 0 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(attribute = nil, direction = nil) @attribute = attribute @direction = direction || :asc end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
it "should send an email using exim" do Mail.defaults do delivery_method :exim end mail = Mail.new do from 'roger@test.lindsaar.net' to 'marcel@test.lindsaar.net, bob@test.lindsaar.net' subject 'invalid RFC2822' end Mail::Exim.should_receive(:call).with('/...
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_update_valid Realm.any_instance.stubs(:valid?).returns(true) realm_id = Realm.unscoped.first.id proxy_id = SmartProxy.unscoped.first.id put :update, {:id => realm_id, :realm => { :realm_proxy_id => proxy_id } }, set_session_user assert_equal proxy_id, Realm.unscoped.find...
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 socket_for(mode) sync unless primaries.any? || (secondaries.any? && mode == :read) server = nil while primaries.any? || (secondaries.any? && mode == :read) if mode == :write || secondaries.empty? server = primaries.sample else server = secondaries.sample ...
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def receive_replies(operations) operations.map do |operation| read if operation.is_a?(Protocol::Query) || operation.is_a?(Protocol::GetMore) end end
1
Ruby
CWE-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_childs(klass, node_id, recursive, ret_obj) SqlHelper.validate_token([node_id]) array = [] if recursive tree = klass.get_tree(Hash.new, nil, node_id) return array if tree.nil? tree.each do |parent_id, childs| if ret_obj array |= childs else ...
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def self.get_group_value(group_id, category, key) SqlHelper.validate_token([group_id, category, key]) con = [] con << "(group_id=#{group_id})" con << "(category='#{category}')" con << "(xkey='#{key}')" setting = Setting.where(con.join(' and ')).first return setting.xvalue unless settin...
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 "has an empty list of dynamic seeds" do cluster.dynamic_seeds.should be_empty 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 test_attr_wrapper assert_equal("<p strange=*attrs*></p>\n", render("%p{ :strange => 'attrs'}", :attr_wrapper => '*')) assert_equal("<p escaped='quo\"te'></p>\n", render("%p{ :escaped => 'quo\"te'}", :attr_wrapper => '"')) assert_equal("<p escaped=\"quo'te\"></p>\n", render("%p{ :escaped => 'quo\\'te'}...
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 kill @node.kill_cursors [@cursor_id] 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 right response' do get "/session/email-login/adasdad" expect(response.status).to eq(200) expect(CGI.unescapeHTML(response.body)).to match( I18n.t('email_login.invalid_token') ) end
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
def self.get_for(user, mail_account_id, xtype) return nil if user.nil? or mail_account_id.blank? if user.kind_of?(User) user_id = user.id else user_id = user.to_s end SqlHelper.validate_token([user_id, mail_account_id, xtype]) con = [] con << "(user_id=#{user_id.to_i})" ...
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def add_colocation_constraint( session, resourceA, resourceB, score, force=false, autocorrect=true ) if score == "" or score == nil score = "INFINITY" end command = [ PCS, "constraint", "colocation", "add", resourceA, resourceB, score ] command << '--force' if force command << '--autocorrect' if 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
def delete_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, false) begin @office_map.destroy rescue => evar Log.add_error(request, evar) ...
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it 'returns a list of all private messages that has been archived' do UserArchivedMessage.archive!(user_2.id, private_message) GroupArchivedMessage.archive!(user_2.id, group_message) topics = TopicQuery.new(nil).list_private_messages_all_archive(user_2).topics expect(topics).to contain_exa...
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 legal?(string) string.to_s =~ /^[0-9a-f]{24}$/i ? true : false end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def validate_each(record, attribute, value) adapter = Paperclip.io_adapters.for(value) if Paperclip::MediaTypeSpoofDetector.using(adapter, value.original_filename).spoofed? record.errors.add(attribute, :spoofed_media_type) end end
0
Ruby
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
it "drops all indexes" do indexes.create name: 1 indexes.create age: 1 indexes.drop indexes[name: 1].should be_nil indexes[age: 1].should be_nil end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def delete_attachment Log.add_info(request, params.inspect) return unless request.post? begin attachment = MailAttachment.find(params[:attachment_id]) @email = Email.find(params[:id]) if attachment.email_id == @email.id attachment.destroy update_attrs = ActionControll...
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def each cursor = Cursor.new(session, operation) cursor.to_enum.tap do |enum| enum.each do |document| yield document end if block_given? 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 initialize(session) @session = session 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 spree_current_user @spree_current_user ||= Spree.user_class.find_by(id: doorkeeper_token.resource_owner_id) if doorkeeper_token end
0
Ruby
CWE-613
Insufficient Session Expiration
According to WASC, "Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization."
https://cwe.mitre.org/data/definitions/613.html
vulnerable
def remove_role(what, role) check_write_access! if what.kind_of? Group rel = self.project_group_role_relationships.where(bs_group_id: what.id) else rel = self.project_user_role_relationships.where(bs_user_id: what.id) end rel = rel.where(role_id: role.id) if role self.transaction ...
1
Ruby
CWE-275
Permission Issues
Weaknesses in this category are related to improper assignment or handling of permissions.
https://cwe.mitre.org/data/definitions/275.html
safe
def test_new_attribute_interpolation assert_equal("<a href='12'>bar</a>\n", render('%a(href="1#{1 + 1}") bar')) assert_equal("<a href='2: 2, 3: 3'>bar</a>\n", render(%q{%a(href='2: #{1 + 1}, 3: #{foo}') bar}, :locals => {:foo => 3})) assert_equal(%Q{<a href='1\#{1 + 1}'>bar</a>\n}, render('%a(href="1\#{1 ...
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-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def test_html5_data_attributes_without_hyphenation assert_equal("<div data-author_id='123' data-biz='baz' data-foo='bar'></div>\n", render("%div{:data => {:author_id => 123, :foo => 'bar', :biz => 'baz'}}", :hyphenate_data_attrs => false)) assert_equal("<div data-one_plus_one='2'></div>\n", ...
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 move_in_team_folder Log.add_info(request, params.inspect) return unless request.post? @item = Item.find(params[:id]) team_folder = @item.team.get_team_folder @item.update_attribute(:folder_id, team_folder.id) flash[:notice] = t('msg.move_success') render(:partial => 'ajax_move_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 call(env) return @app.call(env) unless env['PATH_INFO'].start_with? "#{@bus.base_route}message-bus/_diagnostics" route = env['PATH_INFO'].split("#{@bus.base_route}message-bus/_diagnostics")[1] if @bus.is_admin_lookup.nil? || !@bus.is_admin_lookup.call(env) return [403, {}, ['not allowed']] ...
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 t...
https://cwe.mitre.org/data/definitions/22.html
vulnerable
it "yields a session with the provided options" do session.with(safe: true) do |safe| safe.options[:safe].should eq true 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 destroy Log.add_info(request, params.inspect) return unless request.post? if params[:check_user].nil? list render(:action => 'list') return end count = 0 params[:check_user].each do |user_id, value| if value == '1' SqlHelper.validate_token([user_id]) ...
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it "drops all indexes" do indexes.create name: 1 indexes.create age: 1 indexes.drop indexes[name: 1].should be_nil indexes[age: 1].should be_nil end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def insert(database, collection, documents) with_node do |node| if safe? node.pipeline do node.insert(database, collection, documents) node.command("admin", { getlasterror: 1 }.merge(safety)) end else node.insert(database,...
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 initialize # Generate and cache 3 bytes of identifying information from the current # machine. @machine_id = Digest::MD5.digest(Socket.gethostname).unpack("N")[0] @mutex = Mutex.new @counter = 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 fast_forward_to_first_boundary loop do read_buffer = @io.gets break if read_buffer == full_boundary raise EOFError, "bad content body" if read_buffer.nil? end end
0
Ruby
CWE-119
Improper Restriction of Operations within the Bounds of a Memory Buffer
The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.
https://cwe.mitre.org/data/definitions/119.html
vulnerable
it "has an empty list of servers" do cluster.servers.should be_empty 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 filename_extension File.extname(@name.to_s.downcase).sub(/^\./, '').to_sym 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 to_bson repair!(@data) if defined?(@data) @raw_data ||= @@generator.next 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 ismaster_command?(incoming_message) data = StringIO.new(incoming_message) data.read(20) # header and flags data.gets("\x00") # collection name data.read(8) # skip/limit selector = Moped::BSON::Document.deserialize(data) selector == { "ismaster" => 1 } end
1
Ruby
CWE-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 add_acl_role_remote(params, request, session) if not allowed_for_local_cluster(session, Permissions::GRANT) return 403, 'Permission denied' end retval = add_acl_role(session, params["name"], params["description"]) if retval == "" return [200, "Successfully added ACL role"] else return [ ...
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_copies_folder(user_id) my_folder = User.get_my_folder(user_id) unless my_folder.nil? con = "(parent_id=#{my_folder.id}) and (name='#{Item.copies_folder}')" begin copies_folder = Folder.where(con).first rescue end if copies_folder.nil? folder = Fold...
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 getResourceAgents(session) resource_agent_list = {} stdout, stderr, retval = run_cmd(session, PCS, "resource", "list", "--nodesc") if retval != 0 $logger.error("Error running 'pcs resource list --nodesc") $logger.error(stdout + stderr) return {} end agents = stdout agents.each { |a| ra ...
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