这是indexloc提供的服务,不要输入任何密码
Skip to content

Out of bounds access in core:base64.decode #5911

@FrancisTheCat

Description

@FrancisTheCat

#no_bounds_check {
c0 = DEC_TBL[data[i]]
c1 = DEC_TBL[data[i + 1]]
c2 = DEC_TBL[data[i + 2]]
c3 = DEC_TBL[data[i + 3]]
b0 = (c0 << 2) | (c1 >> 4)
b1 = (c1 << 4) | (c2 >> 2)
b2 = (c2 << 6) | c3
buf[0] = byte(b0)
buf[1] = byte(b1)
buf[2] = byte(b2)
}

The issue is that the DEC_TBL has a size of 128, however the input string could contain non-ascii characters leading to an out of bound access. This does not raise a bounds check error, given that it happens in a #no_bounds_check block. I'm not sure what the best way to fix this is, either increasing the table size or adding bounds checks ig. I would imagine the security impact of this to be relatively small, but given that base64 decoding happens rather frequently in a network context this could be a potential attack vector and should be fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions