It's unusual to have a open black ABS pipe like that. That type of pipe is typically used for plumbing drainage and venting. Could it be a conduit to the attic ??,,,,, but lighter gage white central vacuum pipe is usually used for that ? Lots of homes have conduits from basements to attics so that wires can be easily routed to the attic.
If it is a conduit to the attic then from the attic hatch you may see the other end of it.
What ever it is - put a cap on it.
If it is part of the plumbing system then the cap will need to be glued on with ABS glue. If it is the bottom end of a conduit to the attic then the cap can be taped on or any other effective cap can be used.
https://www.homedepot.ca/en/home/p.2-in-abs-cap--hub.1000176862.html