I have one KVM switch that has a VGA port to connect monitor. I want to know how to test that the KVM switch has no vulnerabilities by this port (using DDC)?
There are I2C lines in the VGA port, that are used to identify which display is connected (maximum resolutions, etc) and to control it if it supports DDC. Thus, bidirectional digital communication is possible.
On the computer side, there could be vulnerabilities in how it parses the EDID sent by the device connected to the VGA port. That could be used to execute malicious code.
On the display device/KVM side, it depends whether a smart device like the main CPU is connected to the I2C bus or if it's just a dumb one like an EEPROM (you can get away with connecting an off the shelf I2C EEPROM with the EDID data in it). In the former case, there is software that interprets the data sent by the computer over I2C - this software could have vulnerabilities and once you can achieve code execution on the KVM you are free to rewrite its firmware to persist. In the latter case, there is no smart device to compromise and you can write a malicious EDID that exploits bugs in connected computers and hope a vulnerable computer is connected.
I don't think it is even possible to use VGA to attack either the monitor or another PC. VGA can only send analog data, which is a one way transmission. As long as this is pure analog data, the monitor itself cannot be exploited either.
Other devices suchs as a mouse or USB stick connected to the KVM can be exploited to store malware and trigger it on a second machine.
If I have misinterpreted your question, please provide additional information.