code
stringlengths
14
2.05k
label
int64
0
1
programming_language
stringclasses
7 values
cwe_id
stringlengths
6
14
cwe_name
stringlengths
5
98
description
stringlengths
36
379
url
stringlengths
36
48
label_name
stringclasses
2 values
func getTokenFromStorage(c *fiber.Ctx, token string, cfg Config, sessionManager *sessionManager, storageManager *storageManager) []byte { if cfg.Session != nil { return sessionManager.getRaw(c, token, dummyValue) } return storageManager.getRaw(token) }
0
Go
CWE-807
Reliance on Untrusted Inputs in a Security Decision
The product uses a protection mechanism that relies on the existence or values of an input, but the input can be modified by an untrusted actor in a way that bypasses the protection mechanism.
https://cwe.mitre.org/data/definitions/807.html
vulnerable
func CsrfFromCookie(param string) func(c *fiber.Ctx) (string, error) { return func(c *fiber.Ctx) (string, error) { token := c.Cookies(param) if token == "" { return "", errMissingCookie } return token, nil } }
0
Go
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
func CsrfFromCookie(param string) func(c *fiber.Ctx) (string, error) { return func(c *fiber.Ctx) (string, error) { token := c.Cookies(param) if token == "" { return "", errMissingCookie } return token, nil } }
0
Go
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
vulnerable
func CsrfFromCookie(param string) func(c *fiber.Ctx) (string, error) { return func(c *fiber.Ctx) (string, error) { token := c.Cookies(param) if token == "" { return "", errMissingCookie } return token, nil } }
0
Go
CWE-565
Reliance on Cookies without Validation and Integrity Checking
The product relies on the existence or values of cookies when performing security-critical operations, but it does not properly ensure that the setting is valid for the associated user.
https://cwe.mitre.org/data/definitions/565.html
vulnerable
func CsrfFromCookie(param string) func(c *fiber.Ctx) (string, error) { return func(c *fiber.Ctx) (string, error) { token := c.Cookies(param) if token == "" { return "", errMissingCookie } return token, nil } }
0
Go
CWE-807
Reliance on Untrusted Inputs in a Security Decision
The product uses a protection mechanism that relies on the existence or values of an input, but the input can be modified by an untrusted actor in a way that bypasses the protection mechanism.
https://cwe.mitre.org/data/definitions/807.html
vulnerable
func CsrfFromHeader(param string) func(c *fiber.Ctx) (string, error) { return func(c *fiber.Ctx) (string, error) { token := c.Get(param) if token == "" { return "", errMissingHeader } return token, nil } }
0
Go
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
func CsrfFromHeader(param string) func(c *fiber.Ctx) (string, error) { return func(c *fiber.Ctx) (string, error) { token := c.Get(param) if token == "" { return "", errMissingHeader } return token, nil } }
0
Go
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
vulnerable
func CsrfFromHeader(param string) func(c *fiber.Ctx) (string, error) { return func(c *fiber.Ctx) (string, error) { token := c.Get(param) if token == "" { return "", errMissingHeader } return token, nil } }
0
Go
CWE-565
Reliance on Cookies without Validation and Integrity Checking
The product relies on the existence or values of cookies when performing security-critical operations, but it does not properly ensure that the setting is valid for the associated user.
https://cwe.mitre.org/data/definitions/565.html
vulnerable
func CsrfFromHeader(param string) func(c *fiber.Ctx) (string, error) { return func(c *fiber.Ctx) (string, error) { token := c.Get(param) if token == "" { return "", errMissingHeader } return token, nil } }
0
Go
CWE-807
Reliance on Untrusted Inputs in a Security Decision
The product uses a protection mechanism that relies on the existence or values of an input, but the input can be modified by an untrusted actor in a way that bypasses the protection mechanism.
https://cwe.mitre.org/data/definitions/807.html
vulnerable
func CsrfFromParam(param string) func(c *fiber.Ctx) (string, error) { return func(c *fiber.Ctx) (string, error) { token := c.Params(param) if token == "" { return "", errMissingParam } return token, nil } }
0
Go
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
func CsrfFromParam(param string) func(c *fiber.Ctx) (string, error) { return func(c *fiber.Ctx) (string, error) { token := c.Params(param) if token == "" { return "", errMissingParam } return token, nil } }
0
Go
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
vulnerable
func CsrfFromParam(param string) func(c *fiber.Ctx) (string, error) { return func(c *fiber.Ctx) (string, error) { token := c.Params(param) if token == "" { return "", errMissingParam } return token, nil } }
0
Go
CWE-565
Reliance on Cookies without Validation and Integrity Checking
The product relies on the existence or values of cookies when performing security-critical operations, but it does not properly ensure that the setting is valid for the associated user.
https://cwe.mitre.org/data/definitions/565.html
vulnerable
func CsrfFromParam(param string) func(c *fiber.Ctx) (string, error) { return func(c *fiber.Ctx) (string, error) { token := c.Params(param) if token == "" { return "", errMissingParam } return token, nil } }
0
Go
CWE-807
Reliance on Untrusted Inputs in a Security Decision
The product uses a protection mechanism that relies on the existence or values of an input, but the input can be modified by an untrusted actor in a way that bypasses the protection mechanism.
https://cwe.mitre.org/data/definitions/807.html
vulnerable
func CsrfFromQuery(param string) func(c *fiber.Ctx) (string, error) { return func(c *fiber.Ctx) (string, error) { token := c.Query(param) if token == "" { return "", errMissingQuery } return token, nil } }
0
Go
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
func CsrfFromQuery(param string) func(c *fiber.Ctx) (string, error) { return func(c *fiber.Ctx) (string, error) { token := c.Query(param) if token == "" { return "", errMissingQuery } return token, nil } }
0
Go
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
vulnerable
func CsrfFromQuery(param string) func(c *fiber.Ctx) (string, error) { return func(c *fiber.Ctx) (string, error) { token := c.Query(param) if token == "" { return "", errMissingQuery } return token, nil } }
0
Go
CWE-565
Reliance on Cookies without Validation and Integrity Checking
The product relies on the existence or values of cookies when performing security-critical operations, but it does not properly ensure that the setting is valid for the associated user.
https://cwe.mitre.org/data/definitions/565.html
vulnerable
func CsrfFromQuery(param string) func(c *fiber.Ctx) (string, error) { return func(c *fiber.Ctx) (string, error) { token := c.Query(param) if token == "" { return "", errMissingQuery } return token, nil } }
0
Go
CWE-807
Reliance on Untrusted Inputs in a Security Decision
The product uses a protection mechanism that relies on the existence or values of an input, but the input can be modified by an untrusted actor in a way that bypasses the protection mechanism.
https://cwe.mitre.org/data/definitions/807.html
vulnerable
func CsrfFromForm(param string) func(c *fiber.Ctx) (string, error) { return func(c *fiber.Ctx) (string, error) { token := c.FormValue(param) if token == "" { return "", errMissingForm } return token, nil } }
0
Go
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
func CsrfFromForm(param string) func(c *fiber.Ctx) (string, error) { return func(c *fiber.Ctx) (string, error) { token := c.FormValue(param) if token == "" { return "", errMissingForm } return token, nil } }
0
Go
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
vulnerable
func CsrfFromForm(param string) func(c *fiber.Ctx) (string, error) { return func(c *fiber.Ctx) (string, error) { token := c.FormValue(param) if token == "" { return "", errMissingForm } return token, nil } }
0
Go
CWE-565
Reliance on Cookies without Validation and Integrity Checking
The product relies on the existence or values of cookies when performing security-critical operations, but it does not properly ensure that the setting is valid for the associated user.
https://cwe.mitre.org/data/definitions/565.html
vulnerable
func CsrfFromForm(param string) func(c *fiber.Ctx) (string, error) { return func(c *fiber.Ctx) (string, error) { token := c.FormValue(param) if token == "" { return "", errMissingForm } return token, nil } }
0
Go
CWE-807
Reliance on Untrusted Inputs in a Security Decision
The product uses a protection mechanism that relies on the existence or values of an input, but the input can be modified by an untrusted actor in a way that bypasses the protection mechanism.
https://cwe.mitre.org/data/definitions/807.html
vulnerable
func NewSortParameter(sort admin.Sort) (SortParameter, error) { var gormOrderExpression string switch sort.Direction { case admin.Sort_DESCENDING: gormOrderExpression = fmt.Sprintf(gormDescending, sort.Key) case admin.Sort_ASCENDING: gormOrderExpression = fmt.Sprintf(gormAscending, sort.Key) default: return nil, errors.NewFlyteAdminErrorf(codes.InvalidArgument, "invalid sort order specified: %v", sort) } return &sortParamImpl{ gormOrderExpression: gormOrderExpression, }, nil }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func TestSortParameter_Descending(t *testing.T) { sortParameter, err := NewSortParameter(admin.Sort{ Direction: admin.Sort_DESCENDING, Key: "project", }) assert.Nil(t, err) assert.Equal(t, "project desc", sortParameter.GetGormOrderExpr()) }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func TestSortParameter_Ascending(t *testing.T) { sortParameter, err := NewSortParameter(admin.Sort{ Direction: admin.Sort_ASCENDING, Key: "name", }) assert.Nil(t, err) assert.Equal(t, "name asc", sortParameter.GetGormOrderExpr()) }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func (m *LaunchPlanManager) ListLaunchPlans(ctx context.Context, request admin.ResourceListRequest) ( *admin.LaunchPlanList, error) { // Check required fields if err := validation.ValidateResourceListRequest(request); err != nil { logger.Debugf(ctx, "") return nil, err } ctx = m.getNamedEntityContext(ctx, request.Id) filters, err := util.GetDbFilters(util.FilterSpec{ Project: request.Id.Project, Domain: request.Id.Domain, Name: request.Id.Name, RequestFilters: request.Filters, }, common.LaunchPlan) if err != nil { return nil, err } var sortParameter common.SortParameter if request.SortBy != nil { sortParameter, err = common.NewSortParameter(*request.SortBy) if err != nil { return nil, err } } offset, err := validation.ValidateToken(request.Token) if err != nil { return nil, errors.NewFlyteAdminErrorf(codes.InvalidArgument, "invalid pagination token %s for ListLaunchPlans", request.Token) } listLaunchPlansInput := repoInterfaces.ListResourceInput{ Limit: int(request.Limit), Offset: offset, InlineFilters: filters, SortParameter: sortParameter, } output, err := m.db.LaunchPlanRepo().List(ctx, listLaunchPlansInput) if err != nil { logger.Debugf(ctx, "Failed to list launch plans for request [%+v] with err %v", request, err) return nil, err } launchPlanList, err := transformers.FromLaunchPlanModels(output.LaunchPlans) if err != nil { logger.Errorf(ctx, "Failed to transform launch plan models [%+v] with err: %v", output.LaunchPlans, err) return nil, err } var token string if len(output.LaunchPlans) == int(request.Limit) { token = strconv.Itoa(offset + len(output.LaunchPlans)) } return &admin.LaunchPlanList{ LaunchPlans: launchPlanList, Token: token, }, nil }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func (m *LaunchPlanManager) ListLaunchPlanIds(ctx context.Context, request admin.NamedEntityIdentifierListRequest) ( *admin.NamedEntityIdentifierList, error) { ctx = contextutils.WithProjectDomain(ctx, request.Project, request.Domain) filters, err := util.GetDbFilters(util.FilterSpec{ Project: request.Project, Domain: request.Domain, }, common.LaunchPlan) if err != nil { return nil, err } var sortParameter common.SortParameter if request.SortBy != nil { sortParameter, err = common.NewSortParameter(*request.SortBy) if err != nil { return nil, err } } offset, err := validation.ValidateToken(request.Token) if err != nil { return nil, errors.NewFlyteAdminErrorf(codes.InvalidArgument, "invalid pagination token %s", request.Token) } listLaunchPlansInput := repoInterfaces.ListResourceInput{ Limit: int(request.Limit), Offset: offset, InlineFilters: filters, SortParameter: sortParameter, } output, err := m.db.LaunchPlanRepo().ListLaunchPlanIdentifiers(ctx, listLaunchPlansInput) if err != nil { logger.Debugf(ctx, "Failed to list launch plan ids for request [%+v] with err %v", request, err) return nil, err } var token string if len(output.LaunchPlans) == int(request.Limit) { token = strconv.Itoa(offset + len(output.LaunchPlans)) } return &admin.NamedEntityIdentifierList{ Entities: transformers.FromLaunchPlanModelsToIdentifiers(output.LaunchPlans), Token: token, }, nil }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func (m *LaunchPlanManager) ListActiveLaunchPlans(ctx context.Context, request admin.ActiveLaunchPlanListRequest) ( *admin.LaunchPlanList, error) { // Check required fields if err := validation.ValidateActiveLaunchPlanListRequest(request); err != nil { logger.Debugf(ctx, "") return nil, err } ctx = contextutils.WithProjectDomain(ctx, request.Project, request.Domain) filters, err := util.ListActiveLaunchPlanVersionsFilters(request.Project, request.Domain) if err != nil { return nil, err } var sortParameter common.SortParameter if request.SortBy != nil { sortParameter, err = common.NewSortParameter(*request.SortBy) if err != nil { return nil, err } } offset, err := validation.ValidateToken(request.Token) if err != nil { return nil, errors.NewFlyteAdminErrorf(codes.InvalidArgument, "invalid pagination token %s for ListActiveLaunchPlans", request.Token) } listLaunchPlansInput := repoInterfaces.ListResourceInput{ Limit: int(request.Limit), Offset: offset, InlineFilters: filters, SortParameter: sortParameter, } output, err := m.db.LaunchPlanRepo().List(ctx, listLaunchPlansInput) if err != nil { logger.Debugf(ctx, "Failed to list active launch plans for request [%+v] with err %v", request, err) return nil, err } launchPlanList, err := transformers.FromLaunchPlanModels(output.LaunchPlans) if err != nil { logger.Errorf(ctx, "Failed to transform active launch plan models [%+v] with err: %v", output.LaunchPlans, err) return nil, err } var token string if len(output.LaunchPlans) == int(request.Limit) { token = strconv.Itoa(offset + len(output.LaunchPlans)) } return &admin.LaunchPlanList{ LaunchPlans: launchPlanList, Token: token, }, nil }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func (m *NodeExecutionManager) listNodeExecutions( ctx context.Context, identifierFilters []common.InlineFilter, requestFilters string, limit uint32, requestToken string, sortBy *admin.Sort, mapFilters []common.MapFilter) ( *admin.NodeExecutionList, error) { filters, err := util.AddRequestFilters(requestFilters, common.NodeExecution, identifierFilters) if err != nil { return nil, err } var sortParameter common.SortParameter if sortBy != nil { sortParameter, err = common.NewSortParameter(*sortBy) if err != nil { return nil, err } } offset, err := validation.ValidateToken(requestToken) if err != nil { return nil, errors.NewFlyteAdminErrorf(codes.InvalidArgument, "invalid pagination token %s for ListNodeExecutions", requestToken) } listInput := repoInterfaces.ListResourceInput{ Limit: int(limit), Offset: offset, InlineFilters: filters, SortParameter: sortParameter, } listInput.MapFilters = mapFilters output, err := m.db.NodeExecutionRepo().List(ctx, listInput) if err != nil { logger.Debugf(ctx, "Failed to list node executions for request with err %v", err) return nil, err } var token string if len(output.NodeExecutions) == int(limit) { token = strconv.Itoa(offset + len(output.NodeExecutions)) } nodeExecutionList, err := m.transformNodeExecutionModelList(ctx, output.NodeExecutions) if err != nil { logger.Debugf(ctx, "failed to transform node execution models for request with err: %v", err) return nil, err } return &admin.NodeExecutionList{ NodeExecutions: nodeExecutionList, Token: token, }, nil }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func TestListNodeExecutions_NothingToReturn(t *testing.T) { repository := repositoryMocks.NewMockRepository() repository.NodeExecutionRepo().(*repositoryMocks.MockNodeExecutionRepo).SetListCallback( func(ctx context.Context, input interfaces.ListResourceInput) ( interfaces.NodeExecutionCollectionOutput, error) { return interfaces.NodeExecutionCollectionOutput{}, nil }) var listExecutionsCalled bool repository.ExecutionRepo().(*repositoryMocks.MockExecutionRepo).SetListCallback( func(ctx context.Context, input interfaces.ListResourceInput) ( interfaces.ExecutionCollectionOutput, error) { listExecutionsCalled = true return interfaces.ExecutionCollectionOutput{}, nil }) nodeExecManager := NewNodeExecutionManager(repository, getMockExecutionsConfigProvider(), make([]string, 0), getMockStorageForExecTest(context.Background()), mockScope.NewTestScope(), mockNodeExecutionRemoteURL, nil, nil, &eventWriterMocks.NodeExecutionEventWriter{}) _, err := nodeExecManager.ListNodeExecutions(context.Background(), admin.NodeExecutionListRequest{ WorkflowExecutionId: &core.WorkflowExecutionIdentifier{ Project: "project", Domain: "domain", Name: "name", }, Limit: 1, Token: "2", SortBy: &admin.Sort{ Direction: admin.Sort_ASCENDING, Key: "domain", }, }) assert.Nil(t, err) assert.False(t, listExecutionsCalled) }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func (m *ProjectManager) ListProjects(ctx context.Context, request admin.ProjectListRequest) (*admin.Projects, error) { spec := util.FilterSpec{ RequestFilters: request.Filters, } filters, err := util.GetDbFilters(spec, common.Project) if err != nil { return nil, err } var sortParameter common.SortParameter if request.SortBy != nil { sortParameter, err = common.NewSortParameter(*request.SortBy) if err != nil { return nil, err } } else { sortParameter = alphabeticalSortParam } offset, err := validation.ValidateToken(request.Token) if err != nil { return nil, errors.NewFlyteAdminErrorf(codes.InvalidArgument, "invalid pagination token %s for ListProjects", request.Token) } // And finally, query the database listProjectsInput := repoInterfaces.ListResourceInput{ Limit: int(request.Limit), Offset: offset, InlineFilters: filters, SortParameter: sortParameter, } projectModels, err := m.db.ProjectRepo().List(ctx, listProjectsInput) if err != nil { return nil, err } projects := transformers.FromProjectModels(projectModels, m.getDomains()) var token string if len(projects) == int(request.Limit) { token = strconv.Itoa(offset + len(projects)) } return &admin.Projects{ Projects: projects, Token: token, }, nil }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func (s *SignalManager) ListSignals(ctx context.Context, request admin.SignalListRequest) (*admin.SignalList, error) { if err := validation.ValidateSignalListRequest(ctx, request); err != nil { logger.Debugf(ctx, "ListSignals request [%+v] is invalid: %v", request, err) return nil, err } ctx = getExecutionContext(ctx, request.WorkflowExecutionId) identifierFilters, err := util.GetWorkflowExecutionIdentifierFilters(ctx, *request.WorkflowExecutionId) if err != nil { return nil, err } filters, err := util.AddRequestFilters(request.Filters, common.Signal, identifierFilters) if err != nil { return nil, err } var sortParameter common.SortParameter if request.SortBy != nil { sortParameter, err = common.NewSortParameter(*request.SortBy) if err != nil { return nil, err } } offset, err := validation.ValidateToken(request.Token) if err != nil { return nil, errors.NewFlyteAdminErrorf(codes.InvalidArgument, "invalid pagination token %s for ListSignals", request.Token) } signalModelList, err := s.db.SignalRepo().List(ctx, repoInterfaces.ListResourceInput{ InlineFilters: filters, Offset: offset, Limit: int(request.Limit), SortParameter: sortParameter, }) if err != nil { logger.Debugf(ctx, "Failed to list signals with request [%+v] with err %v", request, err) return nil, err } signalList, err := transformers.FromSignalModels(signalModelList) if err != nil { logger.Debugf(ctx, "failed to transform signal models for request [%+v] with err: %v", request, err) return nil, err } var token string if len(signalList) == int(request.Limit) { token = strconv.Itoa(offset + len(signalList)) } return &admin.SignalList{ Signals: signalList, Token: token, }, nil }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func (t *TaskManager) ListTasks(ctx context.Context, request admin.ResourceListRequest) (*admin.TaskList, error) { // Check required fields if err := validation.ValidateResourceListRequest(request); err != nil { logger.Debugf(ctx, "Invalid request [%+v]: %v", request, err) return nil, err } ctx = contextutils.WithProjectDomain(ctx, request.Id.Project, request.Id.Domain) ctx = contextutils.WithTaskID(ctx, request.Id.Name) spec := util.FilterSpec{ Project: request.Id.Project, Domain: request.Id.Domain, Name: request.Id.Name, RequestFilters: request.Filters, } filters, err := util.GetDbFilters(spec, common.Task) if err != nil { return nil, err } var sortParameter common.SortParameter if request.SortBy != nil { sortParameter, err = common.NewSortParameter(*request.SortBy) if err != nil { return nil, err } } offset, err := validation.ValidateToken(request.Token) if err != nil { return nil, errors.NewFlyteAdminErrorf(codes.InvalidArgument, "invalid pagination token %s for ListTasks", request.Token) } // And finally, query the database listTasksInput := repoInterfaces.ListResourceInput{ Limit: int(request.Limit), Offset: offset, InlineFilters: filters, SortParameter: sortParameter, } output, err := t.db.TaskRepo().List(ctx, listTasksInput) if err != nil { logger.Debugf(ctx, "Failed to list tasks with id [%+v] with err %v", request.Id, err) return nil, err } taskList, err := transformers.FromTaskModels(output.Tasks) if err != nil { logger.Errorf(ctx, "Failed to transform task models [%+v] with err: %v", output.Tasks, err) return nil, err } var token string if len(taskList) == int(request.Limit) { token = strconv.Itoa(offset + len(taskList)) } return &admin.TaskList{ Tasks: taskList, Token: token, }, nil }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func (t *TaskManager) ListUniqueTaskIdentifiers(ctx context.Context, request admin.NamedEntityIdentifierListRequest) ( *admin.NamedEntityIdentifierList, error) { if err := validation.ValidateNamedEntityIdentifierListRequest(request); err != nil { logger.Debugf(ctx, "invalid request [%+v]: %v", request, err) return nil, err } ctx = contextutils.WithProjectDomain(ctx, request.Project, request.Domain) filters, err := util.GetDbFilters(util.FilterSpec{ Project: request.Project, Domain: request.Domain, }, common.Task) if err != nil { return nil, err } var sortParameter common.SortParameter if request.SortBy != nil { sortParameter, err = common.NewSortParameter(*request.SortBy) if err != nil { return nil, err } } offset, err := validation.ValidateToken(request.Token) if err != nil { return nil, errors.NewFlyteAdminErrorf(codes.InvalidArgument, "invalid pagination token %s for ListUniqueTaskIdentifiers", request.Token) } listTasksInput := repoInterfaces.ListResourceInput{ Limit: int(request.Limit), Offset: offset, InlineFilters: filters, SortParameter: sortParameter, } output, err := t.db.TaskRepo().ListTaskIdentifiers(ctx, listTasksInput) if err != nil { logger.Debugf(ctx, "Failed to list tasks ids with project: %s and domain: %s with err %v", request.Project, request.Domain, err) return nil, err } idList := transformers.FromTaskModelsToIdentifiers(output.Tasks) var token string if len(idList) == int(request.Limit) { token = strconv.Itoa(offset + len(idList)) } return &admin.NamedEntityIdentifierList{ Entities: idList, Token: token, }, nil }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func TestParseFilters(t *testing.T) { filterExpression := "eq(foo, 123)+ne(version, TheWorst)+value_in(bar, 4;5;6)" taskFilters, err := ParseFilters(filterExpression, common.Task) assert.NoError(t, err) assert.Len(t, taskFilters, 3) actualFilterExpression, _ := taskFilters[0].GetGormQueryExpr() assert.Equal(t, "foo = ?", actualFilterExpression.Query) assert.Equal(t, "123", actualFilterExpression.Args) actualFilterExpression, _ = taskFilters[1].GetGormQueryExpr() assert.Equal(t, "version <> ?", actualFilterExpression.Query) assert.Equal(t, "TheWorst", actualFilterExpression.Args) actualFilterExpression, _ = taskFilters[2].GetGormQueryExpr() assert.Equal(t, "bar in (?)", actualFilterExpression.Query) assert.Equal(t, []interface{}{"4", "5", "6"}, actualFilterExpression.Args) filterExpression = "invalid_function(foo,bar)" _, err = ParseFilters(filterExpression, common.Task) assert.Error(t, err) assert.EqualError(t, err, "unrecognized filter function: invalid_function") }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func TestAddRequestFilters(t *testing.T) { filters, err := AddRequestFilters( "ne(version, TheWorst)+eq(workflow.name, workflow)", common.Execution, make([]common.InlineFilter, 0)) assert.Nil(t, err) assert.Len(t, filters, 2) expression, err := filters[0].GetGormQueryExpr() assert.Nil(t, err) assert.Equal(t, "version <> ?", expression.Query) assert.Equal(t, "TheWorst", expression.Args) expression, err = filters[1].GetGormQueryExpr() assert.Nil(t, err) assert.Equal(t, testutils.NameQueryPattern, expression.Query) assert.Equal(t, "workflow", expression.Args) }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func (w *WorkflowManager) ListWorkflows( ctx context.Context, request admin.ResourceListRequest) (*admin.WorkflowList, error) { // Check required fields if err := validation.ValidateResourceListRequest(request); err != nil { return nil, err } ctx = contextutils.WithProjectDomain(ctx, request.Id.Project, request.Id.Domain) ctx = contextutils.WithWorkflowID(ctx, request.Id.Name) filters, err := util.GetDbFilters(util.FilterSpec{ Project: request.Id.Project, Domain: request.Id.Domain, Name: request.Id.Name, RequestFilters: request.Filters, }, common.Workflow) if err != nil { return nil, err } var sortParameter common.SortParameter if request.SortBy != nil { sortParameter, err = common.NewSortParameter(*request.SortBy) if err != nil { return nil, err } } offset, err := validation.ValidateToken(request.Token) if err != nil { return nil, errors.NewFlyteAdminErrorf(codes.InvalidArgument, "invalid pagination token %s for ListWorkflows", request.Token) } listWorkflowsInput := repoInterfaces.ListResourceInput{ Limit: int(request.Limit), Offset: offset, InlineFilters: filters, SortParameter: sortParameter, } output, err := w.db.WorkflowRepo().List(ctx, listWorkflowsInput) if err != nil { logger.Debugf(ctx, "Failed to list workflows with [%+v] with err %v", request.Id, err) return nil, err } workflowList, err := transformers.FromWorkflowModels(output.Workflows) if err != nil { logger.Errorf(ctx, "Failed to transform workflow models [%+v] with err: %v", output.Workflows, err) return nil, err } var token string if len(output.Workflows) == int(request.Limit) { token = strconv.Itoa(offset + len(output.Workflows)) } return &admin.WorkflowList{ Workflows: workflowList, Token: token, }, nil }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func (w *WorkflowManager) ListWorkflowIdentifiers(ctx context.Context, request admin.NamedEntityIdentifierListRequest) ( *admin.NamedEntityIdentifierList, error) { if err := validation.ValidateNamedEntityIdentifierListRequest(request); err != nil { logger.Debugf(ctx, "invalid request [%+v]: %v", request, err) return nil, err } ctx = contextutils.WithProjectDomain(ctx, request.Project, request.Domain) filters, err := util.GetDbFilters(util.FilterSpec{ Project: request.Project, Domain: request.Domain, }, common.Workflow) if err != nil { return nil, err } var sortParameter common.SortParameter if request.SortBy != nil { sortParameter, err = common.NewSortParameter(*request.SortBy) if err != nil { return nil, err } } offset, err := validation.ValidateToken(request.Token) if err != nil { return nil, errors.NewFlyteAdminErrorf(codes.InvalidArgument, "invalid pagination token %s for ListWorkflowIdentifiers", request.Token) } listWorkflowsInput := repoInterfaces.ListResourceInput{ Limit: int(request.Limit), Offset: offset, InlineFilters: filters, SortParameter: sortParameter, } output, err := w.db.WorkflowRepo().ListIdentifiers(ctx, listWorkflowsInput) if err != nil { logger.Debugf(ctx, "Failed to list workflow ids with project: %s and domain: %s with err %v", request.Project, request.Domain, err) return nil, err } var token string if len(output.Workflows) == int(request.Limit) { token = strconv.Itoa(offset + len(output.Workflows)) } entities := transformers.FromWorkflowModelsToIdentifiers(output.Workflows) return &admin.NamedEntityIdentifierList{ Entities: entities, Token: token, }, nil }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func TestListExecutions_Order(t *testing.T) { executionRepo := NewExecutionRepo(GetDbForTest(t), errors.NewTestErrorTransformer(), mockScope.NewTestScope()) executions := make([]map[string]interface{}, 0) GlobalMock := mocket.Catcher.Reset() // Only match on queries that include ordering by name mockQuery := GlobalMock.NewMock().WithQuery(`name asc`) mockQuery.WithReply(executions) sortParameter, _ := common.NewSortParameter(admin.Sort{ Direction: admin.Sort_ASCENDING, Key: "name", }) _, err := executionRepo.List(context.Background(), interfaces.ListResourceInput{ SortParameter: sortParameter, InlineFilters: []common.InlineFilter{ getEqualityFilter(common.Task, "project", project), getEqualityFilter(common.Task, "domain", domain), getEqualityFilter(common.Task, "name", name), }, Limit: 20, }) assert.NoError(t, err) assert.True(t, mockQuery.Triggered) }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func TestListExecutions_WithTags(t *testing.T) { executionRepo := NewExecutionRepo(GetDbForTest(t), errors.NewTestErrorTransformer(), mockScope.NewTestScope()) executions := make([]map[string]interface{}, 0) GlobalMock := mocket.Catcher.Reset() // Only match on queries that include ordering by name mockQuery := GlobalMock.NewMock().WithQuery(`name asc`) mockQuery.WithReply(executions) sortParameter, _ := common.NewSortParameter(admin.Sort{ Direction: admin.Sort_ASCENDING, Key: "name", }) vals := []string{"tag1", "tag2"} tagFilter, err := common.NewRepeatedValueFilter(common.ExecutionAdminTag, common.ValueIn, "admin_tag_name", vals) assert.NoError(t, err) _, err = executionRepo.List(context.Background(), interfaces.ListResourceInput{ SortParameter: sortParameter, InlineFilters: []common.InlineFilter{ getEqualityFilter(common.Task, "project", project), getEqualityFilter(common.Task, "domain", domain), getEqualityFilter(common.Task, "name", name), tagFilter, }, Limit: 20, }) assert.NoError(t, err) assert.True(t, mockQuery.Triggered) }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func TestListLaunchPlans_Order(t *testing.T) { launchPlanRepo := NewLaunchPlanRepo(GetDbForTest(t), errors.NewTestErrorTransformer(), mockScope.NewTestScope()) launchPlans := make([]map[string]interface{}, 0) GlobalMock := mocket.Catcher.Reset() // Only match on queries that include ordering by project mockQuery := GlobalMock.NewMock() mockQuery.WithQuery(`project desc`) mockQuery.WithReply(launchPlans) sortParameter, _ := common.NewSortParameter(admin.Sort{ Direction: admin.Sort_DESCENDING, Key: "project", }) _, err := launchPlanRepo.List(context.Background(), interfaces.ListResourceInput{ SortParameter: sortParameter, InlineFilters: []common.InlineFilter{ getEqualityFilter(common.LaunchPlan, "project", project), getEqualityFilter(common.LaunchPlan, "domain", domain), getEqualityFilter(common.LaunchPlan, "name", name), getEqualityFilter(common.LaunchPlan, "version", version), }, Limit: 20, }) assert.NoError(t, err) assert.True(t, mockQuery.Triggered) }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func TestListNamedEntity(t *testing.T) { metadataRepo := NewNamedEntityRepo(GetDbForTest(t), errors.NewTestErrorTransformer(), mockScope.NewTestScope()) results := make([]map[string]interface{}, 0) metadata := getMockNamedEntityResponseFromDb(models.NamedEntity{ NamedEntityKey: models.NamedEntityKey{ ResourceType: resourceType, Project: project, Domain: domain, Name: name, }, NamedEntityMetadataFields: models.NamedEntityMetadataFields{ Description: description, }, }) results = append(results, metadata) GlobalMock := mocket.Catcher.Reset() GlobalMock.Logging = true mockQuery := GlobalMock.NewMock() mockQuery.WithQuery( `SELECT entities.project,entities.domain,entities.name,'2' AS resource_type,named_entity_metadata.description,named_entity_metadata.state FROM "named_entity_metadata" RIGHT JOIN (SELECT project,domain,name FROM "workflows" WHERE "domain" = $1 AND "project" = $2 GROUP BY project, domain, name ORDER BY name desc LIMIT 20) AS entities ON named_entity_metadata.resource_type = 2 AND named_entity_metadata.project = entities.project AND named_entity_metadata.domain = entities.domain AND named_entity_metadata.name = entities.name GROUP BY entities.project, entities.domain, entities.name, named_entity_metadata.description, named_entity_metadata.state ORDER BY name desc`).WithReply(results) sortParameter, _ := common.NewSortParameter(admin.Sort{ Direction: admin.Sort_DESCENDING, Key: "name", }) output, err := metadataRepo.List(context.Background(), interfaces.ListNamedEntityInput{ ResourceType: resourceType, Project: "admintests", Domain: "development", ListResourceInput: interfaces.ListResourceInput{ Limit: 20, SortParameter: sortParameter, }, }) assert.NoError(t, err) assert.Len(t, output.Entities, 1) }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func TestListNodeExecutions_Order(t *testing.T) { nodeExecutionRepo := NewNodeExecutionRepo(GetDbForTest(t), errors.NewTestErrorTransformer(), mockScope.NewTestScope()) nodeExecutions := make([]map[string]interface{}, 0) GlobalMock := mocket.Catcher.Reset() // Only match on queries that include ordering by project mockQuery := GlobalMock.NewMock() mockQuery.WithQuery(`project desc`) mockQuery.WithReply(nodeExecutions) sortParameter, _ := common.NewSortParameter(admin.Sort{ Direction: admin.Sort_DESCENDING, Key: "project", }) _, err := nodeExecutionRepo.List(context.Background(), interfaces.ListResourceInput{ SortParameter: sortParameter, InlineFilters: []common.InlineFilter{ getEqualityFilter(common.NodeExecution, "phase", nodePhase), }, Limit: 20, }) assert.NoError(t, err) assert.True(t, mockQuery.Triggered) }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func TestListProjects(t *testing.T) { filter, err := common.NewSingleValueFilter(common.Project, common.Equal, "name", "foo") assert.Nil(t, err) testListProjects(interfaces.ListResourceInput{ Offset: 0, Limit: 1, InlineFilters: []common.InlineFilter{filter}, SortParameter: alphabeticalSortParam, }, `SELECT * FROM "projects" WHERE name = $1 ORDER BY identifier asc LIMIT 1`, t) }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func TestListTasks_Order(t *testing.T) { taskRepo := NewTaskRepo(GetDbForTest(t), errors.NewTestErrorTransformer(), mockScope.NewTestScope()) tasks := make([]map[string]interface{}, 0) GlobalMock := mocket.Catcher.Reset() GlobalMock.Logging = true // Only match on queries that include ordering by project mockQuery := GlobalMock.NewMock() mockQuery.WithQuery(`project desc`) mockQuery.WithReply(tasks) sortParameter, _ := common.NewSortParameter(admin.Sort{ Direction: admin.Sort_DESCENDING, Key: "project", }) _, err := taskRepo.List(context.Background(), interfaces.ListResourceInput{ SortParameter: sortParameter, InlineFilters: []common.InlineFilter{ getEqualityFilter(common.Task, "project", project), getEqualityFilter(common.Task, "domain", domain), getEqualityFilter(common.Task, "name", name), getEqualityFilter(common.Task, "version", "ABC"), }, Limit: 20, }) assert.Empty(t, err) assert.True(t, mockQuery.Triggered) }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func TestListWorkflows_Order(t *testing.T) { workflowRepo := NewWorkflowRepo(GetDbForTest(t), errors.NewTestErrorTransformer(), mockScope.NewTestScope()) workflows := make([]map[string]interface{}, 0) GlobalMock := mocket.Catcher.Reset() // Only match on queries that include ordering by project mockQuery := GlobalMock.NewMock() mockQuery.WithQuery(`project desc`) mockQuery.WithReply(workflows) sortParameter, _ := common.NewSortParameter(admin.Sort{ Direction: admin.Sort_DESCENDING, Key: "project", }) _, err := workflowRepo.List(context.Background(), interfaces.ListResourceInput{ SortParameter: sortParameter, InlineFilters: []common.InlineFilter{ getEqualityFilter(common.Workflow, "project", project), getEqualityFilter(common.Workflow, "domain", domain), getEqualityFilter(common.Workflow, "name", name), getEqualityFilter(common.Workflow, "version", "ABC"), }, Limit: 20, }) assert.Empty(t, err) assert.True(t, mockQuery.Triggered) }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func (v *cosignVerifier) VerifySignature(ctx context.Context, opts images.Options) (*images.Response, error) { ref, err := name.ParseReference(opts.ImageRef) if err != nil { return nil, fmt.Errorf("failed to parse image %s", opts.ImageRef) } signatures, bundleVerified, err := tracing.ChildSpan3( ctx, "", "VERIFY IMG SIGS", func(ctx context.Context, span trace.Span) ([]oci.Signature, bool, error) { cosignOpts, err := buildCosignOptions(ctx, opts) if err != nil { return nil, false, err } return client.VerifyImageSignatures(ctx, ref, cosignOpts) }, ) if err != nil { logger.Info("image verification failed", "error", err.Error()) return nil, err } logger.V(3).Info("verified image", "count", len(signatures), "bundleVerified", bundleVerified) payload, err := extractPayload(signatures) if err != nil { return nil, err } if err := matchSignatures(signatures, opts.Subject, opts.Issuer, opts.AdditionalExtensions); err != nil { return nil, err } err = checkAnnotations(payload, opts.Annotations) if err != nil { return nil, err } var digest string if opts.PredicateType == "" { digest, err = extractDigest(opts.ImageRef, payload) if err != nil { return nil, err } } return &images.Response{Digest: digest}, nil }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func (v *cosignVerifier) VerifySignature(ctx context.Context, opts images.Options) (*images.Response, error) { ref, err := name.ParseReference(opts.ImageRef) if err != nil { return nil, fmt.Errorf("failed to parse image %s", opts.ImageRef) } signatures, bundleVerified, err := tracing.ChildSpan3( ctx, "", "VERIFY IMG SIGS", func(ctx context.Context, span trace.Span) ([]oci.Signature, bool, error) { cosignOpts, err := buildCosignOptions(ctx, opts) if err != nil { return nil, false, err } return client.VerifyImageSignatures(ctx, ref, cosignOpts) }, ) if err != nil { logger.Info("image verification failed", "error", err.Error()) return nil, err } logger.V(3).Info("verified image", "count", len(signatures), "bundleVerified", bundleVerified) payload, err := extractPayload(signatures) if err != nil { return nil, err } if err := matchSignatures(signatures, opts.Subject, opts.Issuer, opts.AdditionalExtensions); err != nil { return nil, err } err = checkAnnotations(payload, opts.Annotations) if err != nil { return nil, err } var digest string if opts.PredicateType == "" { digest, err = extractDigest(opts.ImageRef, payload) if err != nil { return nil, err } } return &images.Response{Digest: digest}, nil }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func (v *cosignVerifier) VerifySignature(ctx context.Context, opts images.Options) (*images.Response, error) { ref, err := name.ParseReference(opts.ImageRef) if err != nil { return nil, fmt.Errorf("failed to parse image %s", opts.ImageRef) } signatures, bundleVerified, err := tracing.ChildSpan3( ctx, "", "VERIFY IMG SIGS", func(ctx context.Context, span trace.Span) ([]oci.Signature, bool, error) { cosignOpts, err := buildCosignOptions(ctx, opts) if err != nil { return nil, false, err } return client.VerifyImageSignatures(ctx, ref, cosignOpts) }, ) if err != nil { logger.Info("image verification failed", "error", err.Error()) return nil, err } logger.V(3).Info("verified image", "count", len(signatures), "bundleVerified", bundleVerified) payload, err := extractPayload(signatures) if err != nil { return nil, err } if err := matchSignatures(signatures, opts.Subject, opts.Issuer, opts.AdditionalExtensions); err != nil { return nil, err } err = checkAnnotations(payload, opts.Annotations) if err != nil { return nil, err } var digest string if opts.PredicateType == "" { digest, err = extractDigest(opts.ImageRef, payload) if err != nil { return nil, err } } return &images.Response{Digest: digest}, nil }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func (v *cosignVerifier) VerifySignature(ctx context.Context, opts images.Options) (*images.Response, error) { ref, err := name.ParseReference(opts.ImageRef) if err != nil { return nil, fmt.Errorf("failed to parse image %s", opts.ImageRef) } signatures, bundleVerified, err := tracing.ChildSpan3( ctx, "", "VERIFY IMG SIGS", func(ctx context.Context, span trace.Span) ([]oci.Signature, bool, error) { cosignOpts, err := buildCosignOptions(ctx, opts) if err != nil { return nil, false, err } return client.VerifyImageSignatures(ctx, ref, cosignOpts) }, ) if err != nil { logger.Info("image verification failed", "error", err.Error()) return nil, err } logger.V(3).Info("verified image", "count", len(signatures), "bundleVerified", bundleVerified) payload, err := extractPayload(signatures) if err != nil { return nil, err } if err := matchSignatures(signatures, opts.Subject, opts.Issuer, opts.AdditionalExtensions); err != nil { return nil, err } err = checkAnnotations(payload, opts.Annotations) if err != nil { return nil, err } var digest string if opts.PredicateType == "" { digest, err = extractDigest(opts.ImageRef, payload) if err != nil { return nil, err } } return &images.Response{Digest: digest}, nil }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func matchPredicateType(sig oci.Signature, expectedPredicateType string) (bool, string, error) { if expectedPredicateType != "" { statement, _, err := decodeStatement(sig) if err != nil { return false, "", fmt.Errorf("failed to decode predicateType: %w", err) } if pType, ok := statement["predicateType"]; ok { if pType.(string) == expectedPredicateType { return true, pType.(string), nil } } } return false, "", nil }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func matchPredicateType(sig oci.Signature, expectedPredicateType string) (bool, string, error) { if expectedPredicateType != "" { statement, _, err := decodeStatement(sig) if err != nil { return false, "", fmt.Errorf("failed to decode predicateType: %w", err) } if pType, ok := statement["predicateType"]; ok { if pType.(string) == expectedPredicateType { return true, pType.(string), nil } } } return false, "", nil }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func matchPredicateType(sig oci.Signature, expectedPredicateType string) (bool, string, error) { if expectedPredicateType != "" { statement, _, err := decodeStatement(sig) if err != nil { return false, "", fmt.Errorf("failed to decode predicateType: %w", err) } if pType, ok := statement["predicateType"]; ok { if pType.(string) == expectedPredicateType { return true, pType.(string), nil } } } return false, "", nil }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func matchPredicateType(sig oci.Signature, expectedPredicateType string) (bool, string, error) { if expectedPredicateType != "" { statement, _, err := decodeStatement(sig) if err != nil { return false, "", fmt.Errorf("failed to decode predicateType: %w", err) } if pType, ok := statement["predicateType"]; ok { if pType.(string) == expectedPredicateType { return true, pType.(string), nil } } } return false, "", nil }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func (v *cosignVerifier) FetchAttestations(ctx context.Context, opts images.Options) (*images.Response, error) { cosignOpts, err := buildCosignOptions(ctx, opts) if err != nil { return nil, err } signatures, bundleVerified, err := tracing.ChildSpan3( ctx, "", "VERIFY IMG ATTESTATIONS", func(ctx context.Context, span trace.Span) (checkedAttestations []oci.Signature, bundleVerified bool, err error) { ref, err := name.ParseReference(opts.ImageRef) if err != nil { return nil, false, fmt.Errorf("failed to parse image: %w", err) } return client.VerifyImageAttestations(ctx, ref, cosignOpts) }, ) if err != nil { msg := err.Error() logger.Info("failed to fetch attestations", "error", msg) if strings.Contains(msg, "MANIFEST_UNKNOWN: manifest unknown") { return nil, fmt.Errorf("not found") } return nil, err } payload, err := extractPayload(signatures) if err != nil { return nil, err } for _, signature := range signatures { match, predicateType, err := matchPredicateType(signature, opts.PredicateType) if err != nil { return nil, err } if !match { logger.V(4).Info("predicateType doesn't match, continue", "expected", opts.PredicateType, "received", predicateType) continue } if err := matchSignatures([]oci.Signature{signature}, opts.Subject, opts.Issuer, opts.AdditionalExtensions); err != nil { return nil, err } } err = checkAnnotations(payload, opts.Annotations) if err != nil { return nil, err } logger.V(3).Info("verified images", "signatures", len(signatures), "bundleVerified", bundleVerified) inTotoStatements, digest, err := decodeStatements(signatures) if err != nil { return nil, err } return &images.Response{Digest: digest, Statements: inTotoStatements}, nil }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func (v *cosignVerifier) FetchAttestations(ctx context.Context, opts images.Options) (*images.Response, error) { cosignOpts, err := buildCosignOptions(ctx, opts) if err != nil { return nil, err } signatures, bundleVerified, err := tracing.ChildSpan3( ctx, "", "VERIFY IMG ATTESTATIONS", func(ctx context.Context, span trace.Span) (checkedAttestations []oci.Signature, bundleVerified bool, err error) { ref, err := name.ParseReference(opts.ImageRef) if err != nil { return nil, false, fmt.Errorf("failed to parse image: %w", err) } return client.VerifyImageAttestations(ctx, ref, cosignOpts) }, ) if err != nil { msg := err.Error() logger.Info("failed to fetch attestations", "error", msg) if strings.Contains(msg, "MANIFEST_UNKNOWN: manifest unknown") { return nil, fmt.Errorf("not found") } return nil, err } payload, err := extractPayload(signatures) if err != nil { return nil, err } for _, signature := range signatures { match, predicateType, err := matchPredicateType(signature, opts.PredicateType) if err != nil { return nil, err } if !match { logger.V(4).Info("predicateType doesn't match, continue", "expected", opts.PredicateType, "received", predicateType) continue } if err := matchSignatures([]oci.Signature{signature}, opts.Subject, opts.Issuer, opts.AdditionalExtensions); err != nil { return nil, err } } err = checkAnnotations(payload, opts.Annotations) if err != nil { return nil, err } logger.V(3).Info("verified images", "signatures", len(signatures), "bundleVerified", bundleVerified) inTotoStatements, digest, err := decodeStatements(signatures) if err != nil { return nil, err } return &images.Response{Digest: digest, Statements: inTotoStatements}, nil }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func (v *cosignVerifier) FetchAttestations(ctx context.Context, opts images.Options) (*images.Response, error) { cosignOpts, err := buildCosignOptions(ctx, opts) if err != nil { return nil, err } signatures, bundleVerified, err := tracing.ChildSpan3( ctx, "", "VERIFY IMG ATTESTATIONS", func(ctx context.Context, span trace.Span) (checkedAttestations []oci.Signature, bundleVerified bool, err error) { ref, err := name.ParseReference(opts.ImageRef) if err != nil { return nil, false, fmt.Errorf("failed to parse image: %w", err) } return client.VerifyImageAttestations(ctx, ref, cosignOpts) }, ) if err != nil { msg := err.Error() logger.Info("failed to fetch attestations", "error", msg) if strings.Contains(msg, "MANIFEST_UNKNOWN: manifest unknown") { return nil, fmt.Errorf("not found") } return nil, err } payload, err := extractPayload(signatures) if err != nil { return nil, err } for _, signature := range signatures { match, predicateType, err := matchPredicateType(signature, opts.PredicateType) if err != nil { return nil, err } if !match { logger.V(4).Info("predicateType doesn't match, continue", "expected", opts.PredicateType, "received", predicateType) continue } if err := matchSignatures([]oci.Signature{signature}, opts.Subject, opts.Issuer, opts.AdditionalExtensions); err != nil { return nil, err } } err = checkAnnotations(payload, opts.Annotations) if err != nil { return nil, err } logger.V(3).Info("verified images", "signatures", len(signatures), "bundleVerified", bundleVerified) inTotoStatements, digest, err := decodeStatements(signatures) if err != nil { return nil, err } return &images.Response{Digest: digest, Statements: inTotoStatements}, nil }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func (v *cosignVerifier) FetchAttestations(ctx context.Context, opts images.Options) (*images.Response, error) { cosignOpts, err := buildCosignOptions(ctx, opts) if err != nil { return nil, err } signatures, bundleVerified, err := tracing.ChildSpan3( ctx, "", "VERIFY IMG ATTESTATIONS", func(ctx context.Context, span trace.Span) (checkedAttestations []oci.Signature, bundleVerified bool, err error) { ref, err := name.ParseReference(opts.ImageRef) if err != nil { return nil, false, fmt.Errorf("failed to parse image: %w", err) } return client.VerifyImageAttestations(ctx, ref, cosignOpts) }, ) if err != nil { msg := err.Error() logger.Info("failed to fetch attestations", "error", msg) if strings.Contains(msg, "MANIFEST_UNKNOWN: manifest unknown") { return nil, fmt.Errorf("not found") } return nil, err } payload, err := extractPayload(signatures) if err != nil { return nil, err } for _, signature := range signatures { match, predicateType, err := matchPredicateType(signature, opts.PredicateType) if err != nil { return nil, err } if !match { logger.V(4).Info("predicateType doesn't match, continue", "expected", opts.PredicateType, "received", predicateType) continue } if err := matchSignatures([]oci.Signature{signature}, opts.Subject, opts.Issuer, opts.AdditionalExtensions); err != nil { return nil, err } } err = checkAnnotations(payload, opts.Annotations) if err != nil { return nil, err } logger.V(3).Info("verified images", "signatures", len(signatures), "bundleVerified", bundleVerified) inTotoStatements, digest, err := decodeStatements(signatures) if err != nil { return nil, err } return &images.Response{Digest: digest, Statements: inTotoStatements}, nil }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func substituteVariables(rule kyvernov1.Rule, ctx enginecontext.EvalInterface, logger logr.Logger) (*kyvernov1.Rule, error) { // remove attestations as variables are not substituted in them ruleCopy := *rule.DeepCopy() for i := range ruleCopy.VerifyImages { ruleCopy.VerifyImages[i].Attestations = nil } var err error ruleCopy, err = variables.SubstituteAllInRule(logger, ctx, ruleCopy) if err != nil { return nil, err } // replace attestations for i := range rule.VerifyImages { ruleCopy.VerifyImages[i].Attestations = rule.VerifyImages[i].Attestations } return &ruleCopy, nil }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func substituteVariables(rule kyvernov1.Rule, ctx enginecontext.EvalInterface, logger logr.Logger) (*kyvernov1.Rule, error) { // remove attestations as variables are not substituted in them ruleCopy := *rule.DeepCopy() for i := range ruleCopy.VerifyImages { ruleCopy.VerifyImages[i].Attestations = nil } var err error ruleCopy, err = variables.SubstituteAllInRule(logger, ctx, ruleCopy) if err != nil { return nil, err } // replace attestations for i := range rule.VerifyImages { ruleCopy.VerifyImages[i].Attestations = rule.VerifyImages[i].Attestations } return &ruleCopy, nil }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func substituteVariables(rule kyvernov1.Rule, ctx enginecontext.EvalInterface, logger logr.Logger) (*kyvernov1.Rule, error) { // remove attestations as variables are not substituted in them ruleCopy := *rule.DeepCopy() for i := range ruleCopy.VerifyImages { ruleCopy.VerifyImages[i].Attestations = nil } var err error ruleCopy, err = variables.SubstituteAllInRule(logger, ctx, ruleCopy) if err != nil { return nil, err } // replace attestations for i := range rule.VerifyImages { ruleCopy.VerifyImages[i].Attestations = rule.VerifyImages[i].Attestations } return &ruleCopy, nil }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func substituteVariables(rule kyvernov1.Rule, ctx enginecontext.EvalInterface, logger logr.Logger) (*kyvernov1.Rule, error) { // remove attestations as variables are not substituted in them ruleCopy := *rule.DeepCopy() for i := range ruleCopy.VerifyImages { ruleCopy.VerifyImages[i].Attestations = nil } var err error ruleCopy, err = variables.SubstituteAllInRule(logger, ctx, ruleCopy) if err != nil { return nil, err } // replace attestations for i := range rule.VerifyImages { ruleCopy.VerifyImages[i].Attestations = rule.VerifyImages[i].Attestations } return &ruleCopy, nil }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func (iv *ImageVerifier) buildVerifier( attestor kyvernov1.Attestor, imageVerify kyvernov1.ImageVerification, image string, attestation *kyvernov1.Attestation, ) (images.ImageVerifier, *images.Options, string) { switch imageVerify.Type { case kyvernov1.NotaryV2: return iv.buildNotaryV2Verifier(attestor, imageVerify, image) default: return iv.buildCosignVerifier(attestor, imageVerify, image, attestation) } }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func (iv *ImageVerifier) buildVerifier( attestor kyvernov1.Attestor, imageVerify kyvernov1.ImageVerification, image string, attestation *kyvernov1.Attestation, ) (images.ImageVerifier, *images.Options, string) { switch imageVerify.Type { case kyvernov1.NotaryV2: return iv.buildNotaryV2Verifier(attestor, imageVerify, image) default: return iv.buildCosignVerifier(attestor, imageVerify, image, attestation) } }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func (iv *ImageVerifier) buildVerifier( attestor kyvernov1.Attestor, imageVerify kyvernov1.ImageVerification, image string, attestation *kyvernov1.Attestation, ) (images.ImageVerifier, *images.Options, string) { switch imageVerify.Type { case kyvernov1.NotaryV2: return iv.buildNotaryV2Verifier(attestor, imageVerify, image) default: return iv.buildCosignVerifier(attestor, imageVerify, image, attestation) } }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func (iv *ImageVerifier) buildVerifier( attestor kyvernov1.Attestor, imageVerify kyvernov1.ImageVerification, image string, attestation *kyvernov1.Attestation, ) (images.ImageVerifier, *images.Options, string) { switch imageVerify.Type { case kyvernov1.NotaryV2: return iv.buildNotaryV2Verifier(attestor, imageVerify, image) default: return iv.buildCosignVerifier(attestor, imageVerify, image, attestation) } }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func (iv *ImageVerifier) verifyAttestation(statements []map[string]interface{}, attestation kyvernov1.Attestation, imageInfo apiutils.ImageInfo) error { if attestation.PredicateType == "" { return fmt.Errorf("a predicateType is required") } image := imageInfo.String() statementsByPredicate, types := buildStatementMap(statements) iv.logger.V(4).Info("checking attestations", "predicates", types, "image", image) statements = statementsByPredicate[attestation.PredicateType] if statements == nil { iv.logger.Info("no attestations found for predicate", "type", attestation.PredicateType, "predicates", types, "image", imageInfo.String()) return fmt.Errorf("attestions not found for predicate type %s", attestation.PredicateType) } for _, s := range statements { iv.logger.Info("checking attestation", "predicates", types, "image", imageInfo.String()) val, msg, err := iv.checkAttestations(attestation, s) if err != nil { return fmt.Errorf("failed to check attestations: %w", err) } if !val { return fmt.Errorf("attestation checks failed for %s and predicate %s: %s", imageInfo.String(), attestation.PredicateType, msg) } } return nil }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func (iv *ImageVerifier) verifyAttestation(statements []map[string]interface{}, attestation kyvernov1.Attestation, imageInfo apiutils.ImageInfo) error { if attestation.PredicateType == "" { return fmt.Errorf("a predicateType is required") } image := imageInfo.String() statementsByPredicate, types := buildStatementMap(statements) iv.logger.V(4).Info("checking attestations", "predicates", types, "image", image) statements = statementsByPredicate[attestation.PredicateType] if statements == nil { iv.logger.Info("no attestations found for predicate", "type", attestation.PredicateType, "predicates", types, "image", imageInfo.String()) return fmt.Errorf("attestions not found for predicate type %s", attestation.PredicateType) } for _, s := range statements { iv.logger.Info("checking attestation", "predicates", types, "image", imageInfo.String()) val, msg, err := iv.checkAttestations(attestation, s) if err != nil { return fmt.Errorf("failed to check attestations: %w", err) } if !val { return fmt.Errorf("attestation checks failed for %s and predicate %s: %s", imageInfo.String(), attestation.PredicateType, msg) } } return nil }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func (iv *ImageVerifier) verifyAttestation(statements []map[string]interface{}, attestation kyvernov1.Attestation, imageInfo apiutils.ImageInfo) error { if attestation.PredicateType == "" { return fmt.Errorf("a predicateType is required") } image := imageInfo.String() statementsByPredicate, types := buildStatementMap(statements) iv.logger.V(4).Info("checking attestations", "predicates", types, "image", image) statements = statementsByPredicate[attestation.PredicateType] if statements == nil { iv.logger.Info("no attestations found for predicate", "type", attestation.PredicateType, "predicates", types, "image", imageInfo.String()) return fmt.Errorf("attestions not found for predicate type %s", attestation.PredicateType) } for _, s := range statements { iv.logger.Info("checking attestation", "predicates", types, "image", imageInfo.String()) val, msg, err := iv.checkAttestations(attestation, s) if err != nil { return fmt.Errorf("failed to check attestations: %w", err) } if !val { return fmt.Errorf("attestation checks failed for %s and predicate %s: %s", imageInfo.String(), attestation.PredicateType, msg) } } return nil }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func (iv *ImageVerifier) verifyAttestation(statements []map[string]interface{}, attestation kyvernov1.Attestation, imageInfo apiutils.ImageInfo) error { if attestation.PredicateType == "" { return fmt.Errorf("a predicateType is required") } image := imageInfo.String() statementsByPredicate, types := buildStatementMap(statements) iv.logger.V(4).Info("checking attestations", "predicates", types, "image", image) statements = statementsByPredicate[attestation.PredicateType] if statements == nil { iv.logger.Info("no attestations found for predicate", "type", attestation.PredicateType, "predicates", types, "image", imageInfo.String()) return fmt.Errorf("attestions not found for predicate type %s", attestation.PredicateType) } for _, s := range statements { iv.logger.Info("checking attestation", "predicates", types, "image", imageInfo.String()) val, msg, err := iv.checkAttestations(attestation, s) if err != nil { return fmt.Errorf("failed to check attestations: %w", err) } if !val { return fmt.Errorf("attestation checks failed for %s and predicate %s: %s", imageInfo.String(), attestation.PredicateType, msg) } } return nil }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func (iv *ImageVerifier) buildNotaryV2Verifier( attestor kyvernov1.Attestor, imageVerify kyvernov1.ImageVerification, image string, ) (images.ImageVerifier, *images.Options, string) { path := "" opts := &images.Options{ ImageRef: image, Cert: attestor.Certificates.Certificate, CertChain: attestor.Certificates.CertificateChain, RegistryClient: iv.rclient, } return notaryv2.NewVerifier(), opts, path }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func (iv *ImageVerifier) buildNotaryV2Verifier( attestor kyvernov1.Attestor, imageVerify kyvernov1.ImageVerification, image string, ) (images.ImageVerifier, *images.Options, string) { path := "" opts := &images.Options{ ImageRef: image, Cert: attestor.Certificates.Certificate, CertChain: attestor.Certificates.CertificateChain, RegistryClient: iv.rclient, } return notaryv2.NewVerifier(), opts, path }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func (iv *ImageVerifier) buildNotaryV2Verifier( attestor kyvernov1.Attestor, imageVerify kyvernov1.ImageVerification, image string, ) (images.ImageVerifier, *images.Options, string) { path := "" opts := &images.Options{ ImageRef: image, Cert: attestor.Certificates.Certificate, CertChain: attestor.Certificates.CertificateChain, RegistryClient: iv.rclient, } return notaryv2.NewVerifier(), opts, path }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func (iv *ImageVerifier) buildNotaryV2Verifier( attestor kyvernov1.Attestor, imageVerify kyvernov1.ImageVerification, image string, ) (images.ImageVerifier, *images.Options, string) { path := "" opts := &images.Options{ ImageRef: image, Cert: attestor.Certificates.Certificate, CertChain: attestor.Certificates.CertificateChain, RegistryClient: iv.rclient, } return notaryv2.NewVerifier(), opts, path }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func (p *Parser) isPrefixHeading(data []byte) bool { if data[0] != '#' { return false } if p.extensions&SpaceHeadings != 0 { level := skipCharN(data, 0, '#', 6) if level == len(data) || data[level] != ' ' { return false } } return true }
0
Go
CWE-125
Out-of-bounds Read
The product reads data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/125.html
vulnerable
func (builder *builder) Cmp(i1, i2 frontend.Variable) frontend.Variable { vars, _ := builder.toVariables(i1, i2) bi1 := builder.ToBinary(vars[0], builder.cs.FieldBitLen()) bi2 := builder.ToBinary(vars[1], builder.cs.FieldBitLen()) res := builder.cstZero() for i := builder.cs.FieldBitLen() - 1; i >= 0; i-- { iszeroi1 := builder.IsZero(bi1[i]) iszeroi2 := builder.IsZero(bi2[i]) i1i2 := builder.And(bi1[i], iszeroi2) i2i1 := builder.And(bi2[i], iszeroi1) n := builder.Select(i2i1, -1, 0) m := builder.Select(i1i2, 1, n) res = builder.Select(builder.IsZero(res), m, res).(expr.LinearExpression) } return res }
0
Go
CWE-191
Integer Underflow (Wrap or Wraparound)
The product subtracts one value from another, such that the result is less than the minimum allowable integer value, which produces a value that is not equal to the correct result.
https://cwe.mitre.org/data/definitions/191.html
vulnerable
func (builder *builder) Cmp(i1, i2 frontend.Variable) frontend.Variable { vars, _ := builder.toVariables(i1, i2) bi1 := builder.ToBinary(vars[0], builder.cs.FieldBitLen()) bi2 := builder.ToBinary(vars[1], builder.cs.FieldBitLen()) res := builder.cstZero() for i := builder.cs.FieldBitLen() - 1; i >= 0; i-- { iszeroi1 := builder.IsZero(bi1[i]) iszeroi2 := builder.IsZero(bi2[i]) i1i2 := builder.And(bi1[i], iszeroi2) i2i1 := builder.And(bi2[i], iszeroi1) n := builder.Select(i2i1, -1, 0) m := builder.Select(i1i2, 1, n) res = builder.Select(builder.IsZero(res), m, res).(expr.LinearExpression) } return res }
0
Go
CWE-697
Incorrect Comparison
The product compares two entities in a security-relevant context, but the comparison is incorrect, which may lead to resultant weaknesses.
https://cwe.mitre.org/data/definitions/697.html
vulnerable
func (builder *builder) mustBeLessOrEqVar(a, bound frontend.Variable) { // here bound is NOT a constant, // but a can be either constant or a wire. _, aConst := builder.constantValue(a) debug := builder.newDebugInfo("mustBeLessOrEq", a, " <= ", bound) nbBits := builder.cs.FieldBitLen() aBits := bits.ToBinary(builder, a, bits.WithNbDigits(nbBits), bits.WithUnconstrainedOutputs()) boundBits := builder.ToBinary(bound, nbBits) // constraint added added := make([]int, 0, nbBits) p := make([]frontend.Variable, nbBits+1) p[nbBits] = builder.cstOne() zero := builder.cstZero() for i := nbBits - 1; i >= 0; i-- { // if bound[i] == 0 // p[i] = p[i+1] // t = p[i+1] // else // p[i] = p[i+1] * a[i] // t = 0 v := builder.Mul(p[i+1], aBits[i]) p[i] = builder.Select(boundBits[i], v, p[i+1]) t := builder.Select(boundBits[i], zero, p[i+1]) // (1 - t - ai) * ai == 0 var l frontend.Variable l = builder.cstOne() l = builder.Sub(l, t, aBits[i]) // note if bound[i] == 1, this constraint is (1 - ai) * ai == 0 // → this is a boolean constraint // if bound[i] == 0, t must be 0 or 1, thus ai must be 0 or 1 too if aConst { // aBits[i] is a constant; l = builder.Mul(l, aBits[i]) // TODO @gbotrel this constraint seems useless. added = append(added, builder.cs.AddR1C(builder.newR1C(l, zero, zero), builder.genericGate)) } else { added = append(added, builder.cs.AddR1C(builder.newR1C(l, aBits[i], zero), builder.genericGate)) } } builder.cs.AttachDebugInfo(debug, added) }
0
Go
CWE-191
Integer Underflow (Wrap or Wraparound)
The product subtracts one value from another, such that the result is less than the minimum allowable integer value, which produces a value that is not equal to the correct result.
https://cwe.mitre.org/data/definitions/191.html
vulnerable
func (builder *builder) mustBeLessOrEqVar(a, bound frontend.Variable) { // here bound is NOT a constant, // but a can be either constant or a wire. _, aConst := builder.constantValue(a) debug := builder.newDebugInfo("mustBeLessOrEq", a, " <= ", bound) nbBits := builder.cs.FieldBitLen() aBits := bits.ToBinary(builder, a, bits.WithNbDigits(nbBits), bits.WithUnconstrainedOutputs()) boundBits := builder.ToBinary(bound, nbBits) // constraint added added := make([]int, 0, nbBits) p := make([]frontend.Variable, nbBits+1) p[nbBits] = builder.cstOne() zero := builder.cstZero() for i := nbBits - 1; i >= 0; i-- { // if bound[i] == 0 // p[i] = p[i+1] // t = p[i+1] // else // p[i] = p[i+1] * a[i] // t = 0 v := builder.Mul(p[i+1], aBits[i]) p[i] = builder.Select(boundBits[i], v, p[i+1]) t := builder.Select(boundBits[i], zero, p[i+1]) // (1 - t - ai) * ai == 0 var l frontend.Variable l = builder.cstOne() l = builder.Sub(l, t, aBits[i]) // note if bound[i] == 1, this constraint is (1 - ai) * ai == 0 // → this is a boolean constraint // if bound[i] == 0, t must be 0 or 1, thus ai must be 0 or 1 too if aConst { // aBits[i] is a constant; l = builder.Mul(l, aBits[i]) // TODO @gbotrel this constraint seems useless. added = append(added, builder.cs.AddR1C(builder.newR1C(l, zero, zero), builder.genericGate)) } else { added = append(added, builder.cs.AddR1C(builder.newR1C(l, aBits[i], zero), builder.genericGate)) } } builder.cs.AttachDebugInfo(debug, added) }
0
Go
CWE-697
Incorrect Comparison
The product compares two entities in a security-relevant context, but the comparison is incorrect, which may lead to resultant weaknesses.
https://cwe.mitre.org/data/definitions/697.html
vulnerable
func (builder *builder) AssertIsLessOrEqual(v frontend.Variable, bound frontend.Variable) { cv, vConst := builder.constantValue(v) cb, bConst := builder.constantValue(bound) // both inputs are constants if vConst && bConst { bv, bb := builder.cs.ToBigInt(cv), builder.cs.ToBigInt(cb) if bv.Cmp(bb) == 1 { panic(fmt.Sprintf("AssertIsLessOrEqual: %s > %s", bv.String(), bb.String())) } } // bound is constant if bConst { vv := builder.toVariable(v) builder.mustBeLessOrEqCst(vv, builder.cs.ToBigInt(cb)) return } builder.mustBeLessOrEqVar(v, bound) }
0
Go
CWE-191
Integer Underflow (Wrap or Wraparound)
The product subtracts one value from another, such that the result is less than the minimum allowable integer value, which produces a value that is not equal to the correct result.
https://cwe.mitre.org/data/definitions/191.html
vulnerable
func (builder *builder) AssertIsLessOrEqual(v frontend.Variable, bound frontend.Variable) { cv, vConst := builder.constantValue(v) cb, bConst := builder.constantValue(bound) // both inputs are constants if vConst && bConst { bv, bb := builder.cs.ToBigInt(cv), builder.cs.ToBigInt(cb) if bv.Cmp(bb) == 1 { panic(fmt.Sprintf("AssertIsLessOrEqual: %s > %s", bv.String(), bb.String())) } } // bound is constant if bConst { vv := builder.toVariable(v) builder.mustBeLessOrEqCst(vv, builder.cs.ToBigInt(cb)) return } builder.mustBeLessOrEqVar(v, bound) }
0
Go
CWE-697
Incorrect Comparison
The product compares two entities in a security-relevant context, but the comparison is incorrect, which may lead to resultant weaknesses.
https://cwe.mitre.org/data/definitions/697.html
vulnerable
func (builder *builder) mustBeLessOrEqCst(a expr.LinearExpression, bound *big.Int) { nbBits := builder.cs.FieldBitLen() // ensure the bound is positive, it's bit-len doesn't matter if bound.Sign() == -1 { panic("AssertIsLessOrEqual: bound must be positive") } if bound.BitLen() > nbBits { panic("AssertIsLessOrEqual: bound is too large, constraint will never be satisfied") } // debug info debug := builder.newDebugInfo("mustBeLessOrEq", a, " <= ", builder.toVariable(bound)) // note that at this stage, we didn't boolean-constraint these new variables yet // (as opposed to ToBinary) aBits := bits.ToBinary(builder, a, bits.WithNbDigits(nbBits), bits.WithUnconstrainedOutputs()) // t trailing bits in the bound t := 0 for i := 0; i < nbBits; i++ { if bound.Bit(i) == 0 { break } t++ } // constraint added added := make([]int, 0, nbBits) p := make([]frontend.Variable, nbBits+1) // p[i] == 1 → a[j] == c[j] for all j ⩾ i p[nbBits] = builder.cstOne() for i := nbBits - 1; i >= t; i-- { if bound.Bit(i) == 0 { p[i] = p[i+1] } else { p[i] = builder.Mul(p[i+1], aBits[i]) } } for i := nbBits - 1; i >= 0; i-- { if bound.Bit(i) == 0 { // (1 - p(i+1) - ai) * ai == 0 l := builder.Sub(1, p[i+1]) l = builder.Sub(l, aBits[i]) added = append(added, builder.cs.AddR1C(builder.newR1C(l, aBits[i], builder.cstZero()), builder.genericGate)) } else { builder.AssertIsBoolean(aBits[i]) } } if len(added) != 0 { builder.cs.AttachDebugInfo(debug, added) } }
0
Go
CWE-191
Integer Underflow (Wrap or Wraparound)
The product subtracts one value from another, such that the result is less than the minimum allowable integer value, which produces a value that is not equal to the correct result.
https://cwe.mitre.org/data/definitions/191.html
vulnerable
func (builder *builder) mustBeLessOrEqCst(a expr.LinearExpression, bound *big.Int) { nbBits := builder.cs.FieldBitLen() // ensure the bound is positive, it's bit-len doesn't matter if bound.Sign() == -1 { panic("AssertIsLessOrEqual: bound must be positive") } if bound.BitLen() > nbBits { panic("AssertIsLessOrEqual: bound is too large, constraint will never be satisfied") } // debug info debug := builder.newDebugInfo("mustBeLessOrEq", a, " <= ", builder.toVariable(bound)) // note that at this stage, we didn't boolean-constraint these new variables yet // (as opposed to ToBinary) aBits := bits.ToBinary(builder, a, bits.WithNbDigits(nbBits), bits.WithUnconstrainedOutputs()) // t trailing bits in the bound t := 0 for i := 0; i < nbBits; i++ { if bound.Bit(i) == 0 { break } t++ } // constraint added added := make([]int, 0, nbBits) p := make([]frontend.Variable, nbBits+1) // p[i] == 1 → a[j] == c[j] for all j ⩾ i p[nbBits] = builder.cstOne() for i := nbBits - 1; i >= t; i-- { if bound.Bit(i) == 0 { p[i] = p[i+1] } else { p[i] = builder.Mul(p[i+1], aBits[i]) } } for i := nbBits - 1; i >= 0; i-- { if bound.Bit(i) == 0 { // (1 - p(i+1) - ai) * ai == 0 l := builder.Sub(1, p[i+1]) l = builder.Sub(l, aBits[i]) added = append(added, builder.cs.AddR1C(builder.newR1C(l, aBits[i], builder.cstZero()), builder.genericGate)) } else { builder.AssertIsBoolean(aBits[i]) } } if len(added) != 0 { builder.cs.AttachDebugInfo(debug, added) } }
0
Go
CWE-697
Incorrect Comparison
The product compares two entities in a security-relevant context, but the comparison is incorrect, which may lead to resultant weaknesses.
https://cwe.mitre.org/data/definitions/697.html
vulnerable
func (builder *builder) Cmp(i1, i2 frontend.Variable) frontend.Variable { bi1 := builder.ToBinary(i1, builder.cs.FieldBitLen()) bi2 := builder.ToBinary(i2, builder.cs.FieldBitLen()) var res frontend.Variable res = 0 for i := builder.cs.FieldBitLen() - 1; i >= 0; i-- { iszeroi1 := builder.IsZero(bi1[i]) iszeroi2 := builder.IsZero(bi2[i]) i1i2 := builder.And(bi1[i], iszeroi2) i2i1 := builder.And(bi2[i], iszeroi1) n := builder.Select(i2i1, -1, 0) m := builder.Select(i1i2, 1, n) res = builder.Select(builder.IsZero(res), m, res) } return res }
0
Go
CWE-191
Integer Underflow (Wrap or Wraparound)
The product subtracts one value from another, such that the result is less than the minimum allowable integer value, which produces a value that is not equal to the correct result.
https://cwe.mitre.org/data/definitions/191.html
vulnerable
func (builder *builder) Cmp(i1, i2 frontend.Variable) frontend.Variable { bi1 := builder.ToBinary(i1, builder.cs.FieldBitLen()) bi2 := builder.ToBinary(i2, builder.cs.FieldBitLen()) var res frontend.Variable res = 0 for i := builder.cs.FieldBitLen() - 1; i >= 0; i-- { iszeroi1 := builder.IsZero(bi1[i]) iszeroi2 := builder.IsZero(bi2[i]) i1i2 := builder.And(bi1[i], iszeroi2) i2i1 := builder.And(bi2[i], iszeroi1) n := builder.Select(i2i1, -1, 0) m := builder.Select(i1i2, 1, n) res = builder.Select(builder.IsZero(res), m, res) } return res }
0
Go
CWE-697
Incorrect Comparison
The product compares two entities in a security-relevant context, but the comparison is incorrect, which may lead to resultant weaknesses.
https://cwe.mitre.org/data/definitions/697.html
vulnerable
func (builder *builder) AssertIsLessOrEqual(v frontend.Variable, bound frontend.Variable) { switch b := bound.(type) { case expr.Term: builder.mustBeLessOrEqVar(v, b) default: builder.mustBeLessOrEqCst(v, utils.FromInterface(b)) } }
0
Go
CWE-191
Integer Underflow (Wrap or Wraparound)
The product subtracts one value from another, such that the result is less than the minimum allowable integer value, which produces a value that is not equal to the correct result.
https://cwe.mitre.org/data/definitions/191.html
vulnerable
func (builder *builder) AssertIsLessOrEqual(v frontend.Variable, bound frontend.Variable) { switch b := bound.(type) { case expr.Term: builder.mustBeLessOrEqVar(v, b) default: builder.mustBeLessOrEqCst(v, utils.FromInterface(b)) } }
0
Go
CWE-697
Incorrect Comparison
The product compares two entities in a security-relevant context, but the comparison is incorrect, which may lead to resultant weaknesses.
https://cwe.mitre.org/data/definitions/697.html
vulnerable
func (builder *builder) mustBeLessOrEqCst(a frontend.Variable, bound big.Int) { nbBits := builder.cs.FieldBitLen() // ensure the bound is positive, it's bit-len doesn't matter if bound.Sign() == -1 { panic("AssertIsLessOrEqual: bound must be positive") } if bound.BitLen() > nbBits { panic("AssertIsLessOrEqual: bound is too large, constraint will never be satisfied") } if ca, ok := builder.constantValue(a); ok { // a is constant, compare the big int values ba := builder.cs.ToBigInt(ca) if ba.Cmp(&bound) == 1 { panic(fmt.Sprintf("AssertIsLessOrEqual: %s > %s", ba.String(), bound.String())) } } // debug info debug := builder.newDebugInfo("mustBeLessOrEq", a, " <= ", bound) // note that at this stage, we didn't boolean-constraint these new variables yet // (as opposed to ToBinary) aBits := bits.ToBinary(builder, a, bits.WithNbDigits(nbBits), bits.WithUnconstrainedOutputs()) // t trailing bits in the bound t := 0 for i := 0; i < nbBits; i++ { if bound.Bit(i) == 0 { break } t++ } p := make([]frontend.Variable, nbBits+1) // p[i] == 1 → a[j] == c[j] for all j ⩾ i p[nbBits] = 1 for i := nbBits - 1; i >= t; i-- { if bound.Bit(i) == 0 { p[i] = p[i+1] } else { p[i] = builder.Mul(p[i+1], aBits[i]) } } for i := nbBits - 1; i >= 0; i-- { if bound.Bit(i) == 0 { // (1 - p(i+1) - ai) * ai == 0 l := builder.Sub(1, p[i+1], aBits[i]).(expr.Term) //l = builder.Sub(l, ).(term) builder.addPlonkConstraint(sparseR1C{ xa: l.VID, xb: aBits[i].(expr.Term).VID, qM: builder.tOne, }, debug) } else { builder.AssertIsBoolean(aBits[i]) } } }
0
Go
CWE-191
Integer Underflow (Wrap or Wraparound)
The product subtracts one value from another, such that the result is less than the minimum allowable integer value, which produces a value that is not equal to the correct result.
https://cwe.mitre.org/data/definitions/191.html
vulnerable
func (builder *builder) mustBeLessOrEqCst(a frontend.Variable, bound big.Int) { nbBits := builder.cs.FieldBitLen() // ensure the bound is positive, it's bit-len doesn't matter if bound.Sign() == -1 { panic("AssertIsLessOrEqual: bound must be positive") } if bound.BitLen() > nbBits { panic("AssertIsLessOrEqual: bound is too large, constraint will never be satisfied") } if ca, ok := builder.constantValue(a); ok { // a is constant, compare the big int values ba := builder.cs.ToBigInt(ca) if ba.Cmp(&bound) == 1 { panic(fmt.Sprintf("AssertIsLessOrEqual: %s > %s", ba.String(), bound.String())) } } // debug info debug := builder.newDebugInfo("mustBeLessOrEq", a, " <= ", bound) // note that at this stage, we didn't boolean-constraint these new variables yet // (as opposed to ToBinary) aBits := bits.ToBinary(builder, a, bits.WithNbDigits(nbBits), bits.WithUnconstrainedOutputs()) // t trailing bits in the bound t := 0 for i := 0; i < nbBits; i++ { if bound.Bit(i) == 0 { break } t++ } p := make([]frontend.Variable, nbBits+1) // p[i] == 1 → a[j] == c[j] for all j ⩾ i p[nbBits] = 1 for i := nbBits - 1; i >= t; i-- { if bound.Bit(i) == 0 { p[i] = p[i+1] } else { p[i] = builder.Mul(p[i+1], aBits[i]) } } for i := nbBits - 1; i >= 0; i-- { if bound.Bit(i) == 0 { // (1 - p(i+1) - ai) * ai == 0 l := builder.Sub(1, p[i+1], aBits[i]).(expr.Term) //l = builder.Sub(l, ).(term) builder.addPlonkConstraint(sparseR1C{ xa: l.VID, xb: aBits[i].(expr.Term).VID, qM: builder.tOne, }, debug) } else { builder.AssertIsBoolean(aBits[i]) } } }
0
Go
CWE-697
Incorrect Comparison
The product compares two entities in a security-relevant context, but the comparison is incorrect, which may lead to resultant weaknesses.
https://cwe.mitre.org/data/definitions/697.html
vulnerable
func (builder *builder) mustBeLessOrEqVar(a frontend.Variable, bound expr.Term) { debug := builder.newDebugInfo("mustBeLessOrEq", a, " <= ", bound) nbBits := builder.cs.FieldBitLen() aBits := bits.ToBinary(builder, a, bits.WithNbDigits(nbBits), bits.WithUnconstrainedOutputs()) boundBits := builder.ToBinary(bound, nbBits) p := make([]frontend.Variable, nbBits+1) p[nbBits] = 1 for i := nbBits - 1; i >= 0; i-- { // if bound[i] == 0 // p[i] = p[i+1] // t = p[i+1] // else // p[i] = p[i+1] * a[i] // t = 0 v := builder.Mul(p[i+1], aBits[i]) p[i] = builder.Select(boundBits[i], v, p[i+1]) t := builder.Select(boundBits[i], 0, p[i+1]) // (1 - t - ai) * ai == 0 l := builder.Sub(1, t, aBits[i]).(expr.Term) // note if bound[i] == 1, this constraint is (1 - ai) * ai == 0 // → this is a boolean constraint // if bound[i] == 0, t must be 0 or 1, thus ai must be 0 or 1 too if ai, ok := builder.constantValue(aBits[i]); ok { // a is constant; ensure l == 0 l.Coeff = builder.cs.Mul(l.Coeff, ai) builder.addPlonkConstraint(sparseR1C{ xa: l.VID, qL: l.Coeff, }, debug) } else { // l * a[i] == 0 builder.addPlonkConstraint(sparseR1C{ xa: l.VID, xb: aBits[i].(expr.Term).VID, qM: l.Coeff, }, debug) } } }
0
Go
CWE-191
Integer Underflow (Wrap or Wraparound)
The product subtracts one value from another, such that the result is less than the minimum allowable integer value, which produces a value that is not equal to the correct result.
https://cwe.mitre.org/data/definitions/191.html
vulnerable
func (builder *builder) mustBeLessOrEqVar(a frontend.Variable, bound expr.Term) { debug := builder.newDebugInfo("mustBeLessOrEq", a, " <= ", bound) nbBits := builder.cs.FieldBitLen() aBits := bits.ToBinary(builder, a, bits.WithNbDigits(nbBits), bits.WithUnconstrainedOutputs()) boundBits := builder.ToBinary(bound, nbBits) p := make([]frontend.Variable, nbBits+1) p[nbBits] = 1 for i := nbBits - 1; i >= 0; i-- { // if bound[i] == 0 // p[i] = p[i+1] // t = p[i+1] // else // p[i] = p[i+1] * a[i] // t = 0 v := builder.Mul(p[i+1], aBits[i]) p[i] = builder.Select(boundBits[i], v, p[i+1]) t := builder.Select(boundBits[i], 0, p[i+1]) // (1 - t - ai) * ai == 0 l := builder.Sub(1, t, aBits[i]).(expr.Term) // note if bound[i] == 1, this constraint is (1 - ai) * ai == 0 // → this is a boolean constraint // if bound[i] == 0, t must be 0 or 1, thus ai must be 0 or 1 too if ai, ok := builder.constantValue(aBits[i]); ok { // a is constant; ensure l == 0 l.Coeff = builder.cs.Mul(l.Coeff, ai) builder.addPlonkConstraint(sparseR1C{ xa: l.VID, qL: l.Coeff, }, debug) } else { // l * a[i] == 0 builder.addPlonkConstraint(sparseR1C{ xa: l.VID, xb: aBits[i].(expr.Term).VID, qM: l.Coeff, }, debug) } } }
0
Go
CWE-697
Incorrect Comparison
The product compares two entities in a security-relevant context, but the comparison is incorrect, which may lead to resultant weaknesses.
https://cwe.mitre.org/data/definitions/697.html
vulnerable
func (circuit *recursiveHint) Define(api frontend.API) error { // first hint produces wire w1 w1, _ := api.Compiler().NewHint(make3, 1) // this linear expression is not recorded in a R1CS just yet linearExpression := api.Add(circuit.A, w1[0]) // api.ToBinary calls another hint (bits.NBits) with linearExpression as input // however, when the solver will resolve bits[...] it will need to detect w1 as a dependency // in order to compute the correct linearExpression value bits := api.ToBinary(linearExpression, 10) a := api.FromBinary(bits...) api.AssertIsEqual(a, 45) return nil }
0
Go
CWE-191
Integer Underflow (Wrap or Wraparound)
The product subtracts one value from another, such that the result is less than the minimum allowable integer value, which produces a value that is not equal to the correct result.
https://cwe.mitre.org/data/definitions/191.html
vulnerable
func (circuit *recursiveHint) Define(api frontend.API) error { // first hint produces wire w1 w1, _ := api.Compiler().NewHint(make3, 1) // this linear expression is not recorded in a R1CS just yet linearExpression := api.Add(circuit.A, w1[0]) // api.ToBinary calls another hint (bits.NBits) with linearExpression as input // however, when the solver will resolve bits[...] it will need to detect w1 as a dependency // in order to compute the correct linearExpression value bits := api.ToBinary(linearExpression, 10) a := api.FromBinary(bits...) api.AssertIsEqual(a, 45) return nil }
0
Go
CWE-697
Incorrect Comparison
The product compares two entities in a security-relevant context, but the comparison is incorrect, which may lead to resultant weaknesses.
https://cwe.mitre.org/data/definitions/697.html
vulnerable
func handleRequestBody(c *Client, r *Request) error { var bodyBytes []byte releaseBuffer(r.bodyBuf) r.bodyBuf = nil switch body := r.Body.(type) { case io.Reader: if c.setContentLength || r.setContentLength { // keep backward compatibility r.bodyBuf = acquireBuffer() if _, err := r.bodyBuf.ReadFrom(body); err != nil { return err } r.Body = nil } else { // Otherwise buffer less processing for `io.Reader`, sounds good. return nil } case []byte: bodyBytes = body case string: bodyBytes = []byte(body) default: contentType := r.Header.Get(hdrContentTypeKey) kind := kindOf(r.Body) var err error if IsJSONType(contentType) && (kind == reflect.Struct || kind == reflect.Map || kind == reflect.Slice) { r.bodyBuf, err = jsonMarshal(c, r, r.Body) } else if IsXMLType(contentType) && (kind == reflect.Struct) { bodyBytes, err = c.XMLMarshal(r.Body) } if err != nil { return err } } if bodyBytes == nil && r.bodyBuf == nil { return errors.New("unsupported 'Body' type/value") } // []byte into Buffer if bodyBytes != nil && r.bodyBuf == nil { r.bodyBuf = acquireBuffer() _, _ = r.bodyBuf.Write(bodyBytes) } return nil }
0
Go
CWE-362
Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
The product contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.
https://cwe.mitre.org/data/definitions/362.html
vulnerable
func (s *memoryStore) Verify(id, answer string, clear bool) bool { v := s.Get(id, clear) return v == answer }
0
Go
CWE-345
Insufficient Verification of Data Authenticity
The product does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.
https://cwe.mitre.org/data/definitions/345.html
vulnerable
func (r *RoleBindingReflector) GetUserNamespacesFromRequest(req request.Request) ([]string, error) { var err error username, groups, _ := req.GetUserAndGroups() namespaces := sets.NewString() userOwnerKind := capsulev1beta2.UserOwner var userRoleBindings []interface{} if strings.HasPrefix(username, serviceaccount.ServiceAccountUsernamePrefix) { userOwnerKind = capsulev1beta2.ServiceAccountOwner _, username, err = serviceaccount.SplitUsername(username) if err != nil { return nil, errors.Wrap(err, "Unable to parse serviceAccount name") } } userRoleBindings, err = r.store.ByIndex(subjectIndex, fmt.Sprintf("%s-%s", userOwnerKind, username)) if err != nil { return nil, errors.Wrap(err, "Unable to find rolebindings in index for user") } for _, rb := range userRoleBindings { rb := rb.(*rbacv1.RoleBinding) namespaces.Insert(rb.GetNamespace()) } for _, group := range groups { groupRoleBindings, err := r.store.ByIndex(subjectIndex, fmt.Sprintf("%s-%s", capsulev1beta2.GroupOwner, group)) if err != nil { return nil, errors.Wrap(err, "Unable to find rolebindings in index for groups") } for _, rb := range groupRoleBindings { rb := rb.(*rbacv1.RoleBinding) namespaces.Insert(rb.GetNamespace()) } } return namespaces.List(), nil }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func OwnerRoleBindingsIndexFunc(obj interface{}) (result []string, err error) { rb := obj.(*rbacv1.RoleBinding) for _, subject := range rb.Subjects { result = append(result, fmt.Sprintf("%s-%s", subject.Kind, subject.Name)) } return result, nil }
0
Go
NVD-CWE-noinfo
null
null
null
vulnerable
func (maap *MesheryApplicationPersister) GetMesheryApplications(search, order string, page, pageSize uint64, updatedAfter string) ([]byte, error) { order = sanitizeOrderInput(order, []string{"created_at", "updated_at", "name"}) if order == "" { order = "updated_at desc" } count := int64(0) applications := []*MesheryApplication{} query := maap.DB.Where("updated_at > ?", updatedAfter).Order(order) if search != "" { like := "%" + strings.ToLower(search) + "%" query = query.Where("(lower(meshery_applications.name) like ?)", like) } query.Table("meshery_applications").Count(&count) Paginate(uint(page), uint(pageSize))(query).Find(&applications) mesheryApplicationPage := &MesheryApplicationPage{ Page: page, PageSize: pageSize, TotalCount: int(count), Applications: applications, } return marshalMesheryApplicationPage(mesheryApplicationPage), nil }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func (mfp *MesheryFilterPersister) GetMesheryCatalogFilters(page, pageSize, search, order string) ([]byte, error) { var err error order = sanitizeOrderInput(order, []string{"created_at", "updated_at", "name"}) if order == "" { order = "updated_at desc" } var pg int if page != "" { pg, err = strconv.Atoi(page) if err != nil || pg < 0 { pg = 0 } } else { pg = 0 } // 0 page size is for all records var pgSize int if pageSize != "" { pgSize, err = strconv.Atoi(pageSize) if err != nil || pgSize < 0 { pgSize = 0 } } else { pgSize = 0 } filters := []MesheryFilter{} query := mfp.DB.Where("visibility = ?", Published).Order(order) if search != "" { like := "%" + strings.ToLower(search) + "%" query = query.Where("(lower(meshery_filters.name) like ?)", like) } var count int64 err = query.Model(&MesheryFilter{}).Count(&count).Error if err != nil { return nil, err } if pgSize != 0 { Paginate(uint(pg), uint(pgSize))(query).Find(&filters) } else { query.Find(&filters) } response := FiltersAPIResponse{ Page: uint(pg), PageSize: uint(pgSize), TotalCount: uint(count), Filters: filters, } marshalledResponse, _ := json.Marshal(response) return marshalledResponse, nil }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func (mfp *MesheryFilterPersister) GetMesheryFilters(search, order string, page, pageSize uint64, visibility []string) ([]byte, error) { order = sanitizeOrderInput(order, []string{"created_at", "updated_at", "name"}) if order == "" { order = "updated_at desc" } count := int64(0) filters := []*MesheryFilter{} var query *gorm.DB if len(visibility) == 0 { query = mfp.DB.Where("visibility in (?)", visibility) } query = query.Order(order) if search != "" { like := "%" + strings.ToLower(search) + "%" query = query.Where("(lower(meshery_filters.name) like ?)", like) } query.Table("meshery_filters").Count(&count) Paginate(uint(page), uint(pageSize))(query).Find(&filters) mesheryFilterPage := &MesheryFilterPage{ Page: page, PageSize: pageSize, TotalCount: int(count), Filters: filters, } return marshalMesheryFilterPage(mesheryFilterPage), nil }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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
func (mkcp *MesheryK8sContextPersister) GetMesheryK8sContexts(search, order string, page, pageSize uint64) ([]byte, error) { order = sanitizeOrderInput(order, []string{"created_at", "updated_at", "name"}) if order == "" { order = "updated_at desc" } count := int64(0) contexts := []*K8sContext{} query := mkcp.DB.Order(order) if search != "" { like := "%" + strings.ToLower(search) + "%" query = query.Where("(lower(name) like ?)", like) } query.Model(K8sContext{}).Count(&count) Paginate(uint(page), uint(pageSize))(query).Find(&contexts) mesheryK8sContextPage := MesheryK8sContextPage{ Page: page, PageSize: pageSize, TotalCount: int(count), Contexts: contexts, } resp, _ := json.Marshal(mesheryK8sContextPage) return resp, nil }
0
Go
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product 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