Skip to content

Integer overflow in CPU and memory calculation for instance types #263

@poyrazK

Description

@poyrazK

Why is this an issue?

In \internal/core/services/instance.go:812-813\\, \cpuNano := int64(it.VCPUs) * NanoCPUsPerVCPU\\ and \memoryBytes := int64(it.MemoryMB) * BytesPerMB\\ could overflow if \it.VCPUs\\ or \it.MemoryMB\\ come from untrusted input or DB values with very large values.

What is causing it?

No overflow check before multiplication. If values exceed safe bounds, integer overflow occurs silently.

How can it be solved?

Add overflow checks or use \ MulDiv64\\ or checked arithmetic libraries before multiplication.

Category

  • Small
  • Medium
  • Large

Severity

  • Low
  • Medium
  • High
  • Critical

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions