Entanglement, the essential resource in quantum information processing, should be witnessed in many tasks such as quantum computing and quantum communication. The conventional entanglement witness method, relying on an idealized implementation of measurements, could wrongly conclude a separable state to be entangled due to imperfect detections. Inspired by the idea of a time-shift attack, we construct an attack on the conventional entanglement witness process and demonstrate that a separable state can be falsely identified to be entangled. To close such detection loopholes, based on a recently proposed measurement-device-independent entanglement witness method, we design and experimentally demonstrate a measurement-device-independent entanglement witness for a variety of two-qubit states. By the new scheme, we show that an entanglement witness can be realized without detection loopholes.For more information, click here.