code
stringlengths
14
2.05k
label
int64
0
1
programming_language
stringclasses
7 values
cwe_id
stringlengths
6
14
cwe_name
stringlengths
5
98
description
stringlengths
36
379
url
stringlengths
36
48
label_name
stringclasses
2 values
public void queueFailedPacket(ModernPacket packet, EntityPlayer player) { clientDecompressorThread.queueFailedPacket(packet, player); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
private void handlePacketData(final Pair<EntityPlayer, byte[]> playerDataPair) { try { LPDataIOWrapper.provideData(playerDataPair.getValue2(), input -> { PacketHandler.onPacketData(input, playerDataPair.getValue1()); }); } catch (IOException e) { System.err.println("IO Error in handlePacketData for player " + playerDataPair.getValue1().getCommandSenderName()); e.printStackTrace(); } }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void handlePacket(byte[] content, EntityPlayer player) { serverDecompressorThread.handlePacket(content, player); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
private static byte[] decompress(byte[] contentBytes) { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { GZIPInputStream gzip = new GZIPInputStream(new ByteArrayInputStream(contentBytes)); int buffer = 0; while ((buffer = gzip.read()) != -1) { out.write(buffer); } } catch (IOException e) { throw new RuntimeException(e); } return out.toByteArray(); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void clear(final EntityPlayer player) { new Thread() { @Override public void run() { serverCompressorThread.clear(player); serverDecompressorThread.clear(player); } }.start(); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
private static byte[] compress(byte[] content) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); try { GZIPOutputStream gzipOutputStream = new GZIPOutputStream(byteArrayOutputStream); gzipOutputStream.write(content); gzipOutputStream.close(); } catch (IOException e) { throw new RuntimeException(e); } return byteArrayOutputStream.toByteArray(); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void serverTick(ServerTickEvent event) { if (event.phase != Phase.END) { return; } serverDecompressorThread.serverTickEnd(); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void addPacketToCompressor(ModernPacket packet, EntityPlayer player) { serverCompressorThread.addPacketToCompressor(packet, player); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void setPause(boolean flag) { serverCompressorThread.setPause(flag); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public ServerPacketBufferHandlerThread() {}
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public ExitRoute readExitRoute(World world) throws IOException { IRouter destination = readIRouter(world); IRouter root = readIRouter(world); ForgeDirection exitOri = readForgeDirection(); ForgeDirection insertOri = readForgeDirection(); EnumSet<PipeRoutingConnectionType> connectionDetails = readEnumSet(PipeRoutingConnectionType.class); double distanceToDestination = localBuffer.readDouble(); double destinationDistanceToRoot = localBuffer.readDouble(); int blockDistance = localBuffer.readInt(); List<DoubleCoordinates> positions = readArrayList(LPDataInput::readLPPosition); ExitRoute e = new ExitRoute(root, destination, exitOri, insertOri, destinationDistanceToRoot, connectionDetails, blockDistance); e.distanceToDestination = distanceToDestination; e.debug.filterPosition = positions; e.debug.toStringNetwork = readUTF(); e.debug.isNewlyAddedCanidate = localBuffer.readBoolean(); e.debug.isTraced = localBuffer.readBoolean(); e.debug.index = localBuffer.readInt(); return e; }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void writeExitRoute(ExitRoute route) throws IOException { writeIRouter(route.destination); writeIRouter(route.root); writeForgeDirection(route.exitOrientation); writeForgeDirection(route.insertOrientation); writeEnumSet(route.connectionDetails, PipeRoutingConnectionType.class); writeDouble(route.distanceToDestination); writeDouble(route.destinationDistanceToRoot); writeInt(route.blockDistance); writeCollection(route.filters, (data, filter) -> data.writeLPPosition(filter.getLPPosition())); writeUTF(route.toString()); writeBoolean(route.debug.isNewlyAddedCanidate); writeBoolean(route.debug.isTraced); writeInt(route.debug.index); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public String readUTF() throws IOException { byte[] arr = readByteArray(); if (arr == null) { return null; } else { return new String(arr, UTF_8); } }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public <T> LinkedList<T> readLinkedList(IReadListObject<T> reader) throws IOException { int size = readInt(); if (size == -1) { return null; } LinkedList<T> list = new LinkedList<>(); for (int i = 0; i < size; i++) { list.add(reader.readObject(this)); } return list; }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public <T> ArrayList<T> readArrayList(IReadListObject<T> reader) throws IOException { int size = readInt(); if (size == -1) { return null; } ArrayList<T> list = new ArrayList<>(size); for (int i = 0; i < size; i++) { list.add(reader.readObject(this)); } return list; }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public IOrderInfoProvider readOrderInfo() throws IOException { ItemIdentifierStack stack = readItemIdentifierStack(); int routerId = localBuffer.readInt(); boolean isFinished = localBuffer.readBoolean(); boolean inProgress = localBuffer.readBoolean(); IOrderInfoProvider.ResourceType type = readEnum(IOrderInfoProvider.ResourceType.class); List<Float> list = readArrayList(LPDataInput::readFloat); byte machineProgress = localBuffer.readByte(); DoubleCoordinates pos = readLPPosition(); ItemIdentifier ident = readItemIdentifier(); return new ClientSideOrderInfo(stack, isFinished, type, inProgress, routerId, list, machineProgress, pos, ident); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public static void writeData(ByteBuf dataBuffer, LPDataOutputConsumer dataOutputConsumer) throws IOException { LPDataIOWrapper lpData = getInstance(dataBuffer); dataOutputConsumer.accept(lpData); lpData.unsetBuffer(); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public ItemIdentifier readItemIdentifier() throws IOException { final int itemId = readInt(); if (itemId == 0) { return null; } int damage = readInt(); NBTTagCompound tag = readNBTTagCompound(); return ItemIdentifier.get(Item.getItemById(itemId), damage, tag); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void writeUTF(String s) throws IOException { if (s == null) { writeInt(-1); } else { writeByteArray(s.getBytes(UTF_8)); } }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public boolean[] readBooleanArray() throws IOException { final int bitCount = localBuffer.readInt(); if (bitCount == -1) { return null; } byte[] data = readByteArray(); if (bitCount == 0) { return new boolean[0]; } else if (data == null) { throw new NullPointerException("Boolean's byte array is null"); } BitSet bits = BitSet.valueOf(data); final boolean[] arr = new boolean[bitCount]; IntStream.range(0, bitCount).forEach(i -> arr[i] = bits.get(i)); return arr; }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
private void unsetBuffer() { if (localBuffer.hasMemoryAddress()) { if (--reference < 1) { BUFFER_WRAPPER_MAP.remove(localBuffer.memoryAddress()); } } localBuffer = null; }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public byte[] readByteArray() throws IOException { final int length = readInt(); if (length == -1) { return null; } return readBytes(length); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void writeItemIdentifierStack(ItemIdentifierStack stack) throws IOException { if (stack == null) { writeInt(-1); } else { writeInt(stack.getStackSize()); writeItemIdentifier(stack.getItem()); } }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public ItemStack readItemStack() throws IOException { final int itemId = readInt(); if (itemId == 0) { return null; } int stackSize = readInt(); int damage = readInt(); ItemStack stack = new ItemStack(Item.getItemById(itemId), stackSize, damage); stack.setTagCompound(readNBTTagCompound()); return stack; }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public <T> Set<T> readSet(IReadListObject<T> handler) throws IOException { int size = readInt(); if (size == -1) { return null; } Set<T> set = new HashSet<>(size); for (int i = 0; i < size; i++) { set.add(handler.readObject(this)); } return set; }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void writeNBTTagCompound(NBTTagCompound tag) throws IOException { if (tag == null) { writeByte(0); } else { writeByte(1); CompressedStreamTools.write(tag, new ByteBufOutputStream(localBuffer)); } }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void writeBytes(byte[] arr) throws IOException { localBuffer.writeBytes(arr); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public NBTTagCompound readNBTTagCompound() throws IOException { boolean isEmpty = (readByte() == 0); if (isEmpty) { return null; } return CompressedStreamTools.func_152456_a(new ByteBufInputStream(localBuffer), NBTSizeTracker.field_152451_a); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public <T extends Enum<T>> EnumSet<T> readEnumSet(Class<T> clazz) throws IOException { EnumSet<T> types = EnumSet.noneOf(clazz); byte[] arr = readByteArray(); if (arr != null) { T[] parts = clazz.getEnumConstants(); for (T part : parts) { if ((arr[part.ordinal() / 8] & (1 << (part.ordinal() % 8))) != 0) { types.add(part); } } } return types; }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public ByteBuf readByteBuf() throws IOException { byte[] arr = readByteArray(); if (arr == null) { throw new NullPointerException("Buffer may not be null, but read null"); } else { return wrappedBuffer(arr); } }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void writeByteArray(byte[] arr) throws IOException { if (arr == null) { writeInt(-1); } else { writeInt(arr.length); writeBytes(arr); } }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public ItemIdentifierStack readItemIdentifierStack() throws IOException { int stacksize = readInt(); if (stacksize == -1) { return null; } ItemIdentifier item = readItemIdentifier(); return new ItemIdentifierStack(item, stacksize); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void writeItemStack(ItemStack itemstack) throws IOException { if (itemstack == null) { writeInt(0); } else { writeInt(Item.getIdFromItem(itemstack.getItem())); writeInt(itemstack.stackSize); writeInt(itemstack.getItemDamage()); writeNBTTagCompound(itemstack.getTagCompound()); } }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void writeResource(IResource res) throws IOException { ResourceNetwork.writeResource(this, res); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public <T extends Enum<T>> void writeEnumSet(EnumSet<T> types, Class<T> clazz) throws IOException { T[] parts = clazz.getEnumConstants(); final int length = parts.length / 8 + (parts.length % 8 == 0 ? 0 : 1); byte[] set = new byte[length]; for (T part : parts) { if (types.contains(part)) { byte i = (byte) (1 << (part.ordinal() % 8)); set[part.ordinal() / 8] |= i; } } writeByteArray(set); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void writeBooleanArray(boolean[] arr) throws IOException { if (arr == null) { writeInt(-1); } else if (arr.length == 0) { writeInt(0); writeByteArray(null); } else { BitSet bits = new BitSet(arr.length); for (int i = 0; i < arr.length; i++) { bits.set(i, arr[i]); } writeInt(arr.length); writeByteArray(bits.toByteArray()); } }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public byte[] readBytes(int length) throws IOException { byte[] arr = new byte[length]; localBuffer.readBytes(arr, 0, length); return arr; }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void writeItemIdentifier(ItemIdentifier item) throws IOException { if (item == null) { writeInt(0); } else { writeInt(Item.getIdFromItem(item.item)); writeInt(item.itemDamage); writeNBTTagCompound(item.tag); } }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public LinkedLogisticsOrderList readLinkedLogisticsOrderList() throws IOException { LinkedLogisticsOrderList list = new LinkedLogisticsOrderList(); List<IOrderInfoProvider> orderInfoProviders = readArrayList(LPDataInput::readOrderInfo); if (orderInfoProviders == null) { throw new IOException("Expected order info provider list"); } list.addAll(orderInfoProviders); List<LinkedLogisticsOrderList> orderLists = readArrayList(LPDataInput::readLinkedLogisticsOrderList); if (orderLists == null) { throw new IOException("Expected logistics order list"); } list.getSubOrders().addAll(orderLists); return list; }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public IResource readResource() throws IOException { return ResourceNetwork.readResource(this); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void writeBitSet(BitSet bits) throws IOException { if (bits == null) { throw new NullPointerException("BitSet may not be null"); } writeByteArray(bits.toByteArray()); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public static byte[] collectData(LPDataOutputConsumer dataOutputConsumer) throws IOException { ByteBuf dataBuffer = buffer(); LPDataIOWrapper lpData = getInstance(dataBuffer); dataOutputConsumer.accept(lpData); lpData.unsetBuffer(); byte[] data = new byte[dataBuffer.readableBytes()]; dataBuffer.getBytes(0, data); dataBuffer.release(); return data; }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void writeOrderInfo(IOrderInfoProvider order) throws IOException { writeItemIdentifierStack(order.getAsDisplayItem()); writeInt(order.getRouterId()); writeBoolean(order.isFinished()); writeBoolean(order.isInProgress()); writeEnum(order.getType()); writeCollection(order.getProgresses(), LPDataOutput::writeFloat); writeByte(order.getMachineProgress()); writeLPPosition(order.getTargetPosition()); writeItemIdentifier(order.getTargetType()); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public <T> void writeCollection(Collection<T> collection, IWriteListObject<T> handler) throws IOException { if (collection == null) { writeInt(-1); } else { writeInt(collection.size()); for (T obj : collection) { handler.writeObject(this, obj); } } }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public static void provideData(ByteBuf dataBuffer, LPDataInputConsumer dataInputConsumer) throws IOException { LPDataIOWrapper lpData = getInstance(dataBuffer); dataInputConsumer.accept(lpData); lpData.unsetBuffer(); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public BitSet readBitSet() throws IOException { byte[] arr = readByteArray(); if (arr == null) { return new BitSet(); } else { return BitSet.valueOf(arr); } }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public static void provideData(byte[] data, LPDataInputConsumer dataInputConsumer) throws IOException { ByteBuf dataBuffer = wrappedBuffer(data); LPDataIOWrapper lpData = getInstance(dataBuffer); dataInputConsumer.accept(lpData); lpData.unsetBuffer(); dataBuffer.release(); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void writeLinkedLogisticsOrderList(LinkedLogisticsOrderList orderList) throws IOException { writeCollection(orderList, LPDataOutput::writeOrderInfo); writeCollection(orderList.getSubOrders(), LPDataOutput::writeLinkedLogisticsOrderList); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void testNullArrayList() throws Exception { byte[] data = LPDataIOWrapper.collectData(output -> output.writeCollection(null, LPDataOutput::writeUTF)); LPDataIOWrapper.provideData(data, input -> { assertEquals(null, input.readArrayList(LPDataInput::readUTF)); assertEquals(BUFFER_EMPTY_MSG, 0, ((LPDataIOWrapper) input).localBuffer.readableBytes()); }); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void testArrayList() throws Exception { ArrayList<String> arrayList = new ArrayList<>(); arrayList.add("drölf"); arrayList.add("text"); byte[] data = LPDataIOWrapper.collectData(output -> output.writeCollection(arrayList, LPDataOutput::writeUTF)); LPDataIOWrapper.provideData(data, input -> { assertEquals(arrayList, input.readArrayList(LPDataInput::readUTF)); assertEquals(BUFFER_EMPTY_MSG, 0, ((LPDataIOWrapper) input).localBuffer.readableBytes()); }); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void testLinkedList() throws Exception { LinkedList<String> linkedList = new LinkedList<>(); linkedList.add("drölf"); linkedList.add("text"); byte[] data = LPDataIOWrapper.collectData(output -> output.writeCollection(linkedList, LPDataOutput::writeUTF)); LPDataIOWrapper.provideData(data, input -> { assertEquals(linkedList, input.readLinkedList(LPDataInput::readUTF)); assertEquals(BUFFER_EMPTY_MSG, 0, ((LPDataIOWrapper) input).localBuffer.readableBytes()); }); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void testNullSet() throws Exception { byte[] data = LPDataIOWrapper.collectData(output -> output.writeCollection(null, LPDataOutput::writeUTF)); LPDataIOWrapper.provideData(data, input -> { assertEquals(null, input.readSet(LPDataInput::readUTF)); assertEquals(BUFFER_EMPTY_MSG, 0, ((LPDataIOWrapper) input).localBuffer.readableBytes()); }); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void testSet() throws Exception { HashSet<String> set = new HashSet<>(); set.add("drölf"); set.add("text"); byte[] data = LPDataIOWrapper.collectData(output -> output.writeCollection(set, LPDataOutput::writeUTF)); LPDataIOWrapper.provideData(data, input -> { assertEquals(set, input.readSet(LPDataInput::readUTF)); assertEquals(BUFFER_EMPTY_MSG, 0, ((LPDataIOWrapper) input).localBuffer.readableBytes()); }); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void testNullLinkedList() throws Exception { byte[] data = LPDataIOWrapper.collectData(output -> output.writeCollection(null, LPDataOutput::writeUTF)); LPDataIOWrapper.provideData(data, input -> { assertEquals(null, input.readLinkedList(LPDataInput::readUTF)); assertEquals(BUFFER_EMPTY_MSG, 0, ((LPDataIOWrapper) input).localBuffer.readableBytes()); }); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public static Service getService(Map environment) { Service service = null; InitialContext context = null; EngineConfiguration configProvider = (EngineConfiguration)environment.get(EngineConfiguration.PROPERTY_NAME); if (configProvider == null) configProvider = (EngineConfiguration)threadDefaultConfig.get(); if (configProvider == null) configProvider = getDefaultEngineConfig(); // First check to see if JNDI works // !!! Might we need to set up context parameters here? try { context = new InitialContext(); } catch (NamingException e) { } if (context != null) { String name = (String)environment.get("jndiName"); if(name!=null && (name.toUpperCase().indexOf("LDAP")!=-1 || name.toUpperCase().indexOf("RMI")!=-1 || name.toUpperCase().indexOf("JMS")!=-1 || name.toUpperCase().indexOf("JMX")!=-1) || name.toUpperCase().indexOf("JRMP")!=-1 || name.toUpperCase().indexOf("JAVA")!=-1 || name.toUpperCase().indexOf("DNS")!=-1) { return null; } if (name == null) { name = "axisServiceName"; } // We've got JNDI, so try to find an AxisClient at the // specified name. try { service = (Service)context.lookup(name); } catch (NamingException e) { service = new Service(configProvider); try { context.bind(name, service); } catch (NamingException e1) { // !!! Couldn't do it, what should we do here? return null; } } } else { service = new Service(configProvider); } return service; }
0
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
private DDFFileParser(DDFFileValidator ddfValidator, DDFFileValidatorFactory ddfFileValidatorFactory) { factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); this.ddfValidator = ddfValidator; this.ddfValidatorFactory = ddfFileValidatorFactory; }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
protected Schema getEmbeddedLwM2mSchema() throws SAXException { InputStream inputStream = DDFFileValidator.class.getResourceAsStream(schema); Source source = new StreamSource(inputStream); SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); return schemaFactory.newSchema(source); }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public void load(Reader r) { Document document = null; try { DocumentBuilder parser = DocumentBuilderFactory.newInstance() .newDocumentBuilder(); // parser.setProcessNamespace(true); document = parser.parse(new InputSource(r)); //Strip out any comments first Node root = document.getFirstChild(); while (root.getNodeType() == Node.COMMENT_NODE) { document.removeChild(root); root = document.getFirstChild(); } load(document, (Element) root); } catch (ParserConfigurationException | IOException | SAXException e) { // ignore } }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public void parseInputStream(InputStream is, boolean expandURLs) { documentBuilderFactory.setNamespaceAware(true); documentBuilderFactory.setIgnoringComments(true); reset(); try { DocumentBuilder parser = documentBuilderFactory .newDocumentBuilder(); parser.setErrorHandler(new ParseErrorHandler()); InputSource source = new InputSource(is); Document doc = parser.parse(source); processDocument(doc, expandURLs); } catch (ParserConfigurationException | SAXException e) { SWT.error(SWT.ERROR_INVALID_ARGUMENT, e, " " + e.getMessage()); //$NON-NLS-1$ } catch (IOException e) { SWT.error(SWT.ERROR_IO, e); } }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public void gotoMarker(IMarker marker) { // do nothing }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public void read(InputStream is) throws IOException { try { parser = new WelcomeParser(); } catch (ParserConfigurationException | SAXException e) { throw (IOException) (new IOException().initCause(e)); } parser.parse(is); }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public WelcomeParser() throws ParserConfigurationException, SAXException, FactoryConfigurationError { super(); SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setFeature("http://xml.org/sax/features/namespaces", true); //$NON-NLS-1$ parser = factory.newSAXParser(); parser.getXMLReader().setContentHandler(this); parser.getXMLReader().setDTDHandler(this); parser.getXMLReader().setEntityResolver(this); parser.getXMLReader().setErrorHandler(this); }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
private static String getAttributeNewValue(Object attributeOldValue) { StringBuilder strNewValue = new StringBuilder(FILE_STRING); if (attributeOldValue instanceof String && ((String) attributeOldValue).length() != 0) { String strOldValue = (String) attributeOldValue; boolean exists = Arrays.asList(strOldValue.split(",")).stream().anyMatch(x -> x.trim().equals(FILE_STRING)); //$NON-NLS-1$ if (!exists) { strNewValue.append(", ").append(strOldValue); //$NON-NLS-1$ } else { strNewValue = new StringBuilder(strOldValue); } } return strNewValue.toString(); }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public static XMLMemento createWriteRoot(String type) throws DOMException { Document document; try { document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); Element element = document.createElement(type); document.appendChild(element); return new XMLMemento(document, element); } catch (ParserConfigurationException e) { // throw new Error(e); throw new Error(e.getMessage()); } }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
private void close(Closeable closeable) { try { closeable.close(); } catch (IOException e) { throw new IllegalStateException(e); } }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
private void transformDocument(Writer writer) { try { DOMSource source = new DOMSource(this.document); TransformerFactory.newInstance().newTransformer().transform(source, new StreamResult(writer)); } catch (TransformerException e) { throw new IllegalStateException(e); } finally { close(writer); } }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
private Document getDom(Reader reader) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(new InputSource(reader)); } catch (ParserConfigurationException | IOException | SAXException e) { throw new IllegalArgumentException(e); } finally { close(reader); } }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
private static DocumentBuilder createDocumentBuilder() throws ParserConfigurationException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); return factory.newDocumentBuilder(); }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public static Document createDocument(String name) throws ParserConfigurationException { Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); doc.appendChild(doc.createElement(name)); return doc; }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
static private String docToString(Document doc) throws TransformerException { final TransformerFactory tf = TransformerFactory.newInstance(); final Transformer transformer = tf.newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); //$NON-NLS-1$ final StringWriter writer = new StringWriter(); transformer.transform(new DOMSource(doc), new StreamResult(writer)); final String output = writer.getBuffer().toString().replaceAll("\n|\r", ""); //$NON-NLS-1$ //$NON-NLS-2$ return output; }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
static private List<String> getOutputDirectories(String installLocation) { List<String> ret = outputDirectories.get(installLocation); if (ret == null) { ret = new ArrayList<>(); outputDirectories.put(installLocation, ret); try { final Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder() .parse(new File(installLocation + File.separator + ".classpath")); //$NON-NLS-1$ final XPath xp = XPathFactory.newInstance().newXPath(); final NodeList list = (NodeList) xp.evaluate( "//classpathentry[@kind='output']/@path", doc, XPathConstants.NODESET); //$NON-NLS-1$ for (int i = 0; i < list.getLength(); i++) { final String value = list.item(i).getNodeValue(); ret.add(value); } } catch (final Exception e) { } } return ret; }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public static TestRunSession importTestRunSession(File file) throws CoreException { try { SAXParserFactory parserFactory= SAXParserFactory.newInstance(); // parserFactory.setValidating(true); // TODO: add DTD and debug flag SAXParser parser= parserFactory.newSAXParser(); TestRunHandler handler= new TestRunHandler(); parser.parse(file, handler); TestRunSession session= handler.getTestRunSession(); JUnitCorePlugin.getModel().addTestRunSession(session); return session; } catch (ParserConfigurationException | SAXException e) { throwImportError(file, e); } catch (IOException e) { throwImportError(file, e); } catch (IllegalArgumentException e) { // Bug in parser: can throw IAE even if file is not null throwImportError(file, e); } return null; // does not happen }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public static void exportTestRunSession(TestRunSession testRunSession, OutputStream out) throws TransformerFactoryConfigurationError, TransformerException { Transformer transformer= TransformerFactory.newInstance().newTransformer(); InputSource inputSource= new InputSource(); SAXSource source= new SAXSource(new TestRunSessionSerializer(testRunSession), inputSource); StreamResult result= new StreamResult(out); transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ /* * Bug in Xalan: Only indents if proprietary property * org.apache.xalan.templates.OutputProperties.S_KEY_INDENT_AMOUNT is set. * * Bug in Xalan as shipped with J2SE 5.0: * Does not read the indent-amount property at all >:-(. */ try { transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "2"); //$NON-NLS-1$ //$NON-NLS-2$ } catch (IllegalArgumentException e) { // no indentation today... } transformer.transform(source, result); }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public static void importIntoTestRunSession(File swapFile, TestRunSession testRunSession) throws CoreException { try { SAXParserFactory parserFactory= SAXParserFactory.newInstance(); // parserFactory.setValidating(true); // TODO: add DTD and debug flag SAXParser parser= parserFactory.newSAXParser(); TestRunHandler handler= new TestRunHandler(testRunSession); parser.parse(swapFile, handler); } catch (ParserConfigurationException | SAXException e) { throwImportError(swapFile, e); } catch (IOException e) { throwImportError(swapFile, e); } catch (IllegalArgumentException e) { // Bug in parser: can throw IAE even if file is not null throwImportError(swapFile, e); } }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public static TestRunSession importTestRunSession(String url, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(ModelMessages.JUnitModel_importing_from_url, IProgressMonitor.UNKNOWN); final String trimmedUrl= url.trim().replaceAll("\r\n?|\n", ""); //$NON-NLS-1$ //$NON-NLS-2$ final TestRunHandler handler= new TestRunHandler(monitor); final CoreException[] exception= { null }; final TestRunSession[] session= { null }; Thread importThread= new Thread("JUnit URL importer") { //$NON-NLS-1$ @Override public void run() { try { SAXParserFactory parserFactory= SAXParserFactory.newInstance(); // parserFactory.setValidating(true); // TODO: add DTD and debug flag SAXParser parser= parserFactory.newSAXParser(); parser.parse(trimmedUrl, handler); session[0]= handler.getTestRunSession(); } catch (OperationCanceledException e) { // canceled } catch (ParserConfigurationException | SAXException e) { storeImportError(e); } catch (IOException e) { storeImportError(e); } catch (IllegalArgumentException e) { // Bug in parser: can throw IAE even if URL is not null storeImportError(e); } } private void storeImportError(Exception e) { exception[0]= new CoreException(new org.eclipse.core.runtime.Status(IStatus.ERROR, JUnitCorePlugin.getPluginId(), ModelMessages.JUnitModel_could_not_import, e)); } }; importThread.start(); while (session[0] == null && exception[0] == null && !monitor.isCanceled()) { try { Thread.sleep(100); } catch (InterruptedException e) { // that's OK } } if (session[0] == null) { if (exception[0] != null) { throw new InvocationTargetException(exception[0]); } else { importThread.interrupt(); // have to kill the thread since we don't control URLConnection and XML parsing throw new InterruptedException(); } } JUnitCorePlugin.getModel().addTestRunSession(session[0]); monitor.done(); return session[0]; }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
private static Element readXML(IPath xmlFilePath) throws Exception { try (InputStream in = new FileInputStream(xmlFilePath.toFile())) { DocumentBuilder parser= DocumentBuilderFactory.newInstance().newDocumentBuilder(); parser.setErrorHandler(new DefaultHandler()); Element root= parser.parse(new InputSource(in)).getDocumentElement(); in.close(); return root; } }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public void saveToStream(OutputStream stream) throws CoreException { try { DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance(); DocumentBuilder builder= factory.newDocumentBuilder(); Document document= builder.newDocument(); Node root= document.createElement("templates"); //$NON-NLS-1$ document.appendChild(root); for (Template template : fTemplates) { Node node= document.createElement(getTemplateTag()); root.appendChild(node); NamedNodeMap attributes= node.getAttributes(); Attr name= document.createAttribute(NAME_ATTRIBUTE); name.setValue(template.getName()); attributes.setNamedItem(name); Attr description= document.createAttribute(DESCRIPTION_ATTRIBUTE); description.setValue(template.getDescription()); attributes.setNamedItem(description); Attr context= document.createAttribute(CONTEXT_ATTRIBUTE); context.setValue(template.getContextTypeId()); attributes.setNamedItem(context); Text pattern= document.createTextNode(template.getPattern()); node.appendChild(pattern); } Transformer transformer=TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$ DOMSource source = new DOMSource(document); StreamResult result = new StreamResult(stream); transformer.transform(source, result); } catch (ParserConfigurationException | TransformerException e) { throwWriteException(e); } }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public void addFromStream(InputStream stream, boolean allowDuplicates) throws CoreException { try { DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance(); DocumentBuilder parser= factory.newDocumentBuilder(); parser.setErrorHandler(new DefaultHandler()); Document document= parser.parse(new InputSource(stream)); NodeList elements= document.getElementsByTagName(getTemplateTag()); int count= elements.getLength(); for (int i= 0; i != count; i++) { Node node= elements.item(i); NamedNodeMap attributes= node.getAttributes(); if (attributes == null) continue; String name= getAttributeValue(attributes, NAME_ATTRIBUTE); String description= getAttributeValue(attributes, DESCRIPTION_ATTRIBUTE); if (name == null || description == null) continue; String context= getAttributeValue(attributes, CONTEXT_ATTRIBUTE); if (context == null) throw new SAXException(JavaTemplateMessages.TemplateSet_error_missing_attribute); StringBuilder buffer= new StringBuilder(); NodeList children= node.getChildNodes(); for (int j= 0; j != children.getLength(); j++) { String value= children.item(j).getNodeValue(); if (value != null) buffer.append(value); } String pattern= buffer.toString().trim(); Template template= new Template(name, description, context, pattern, true); String message= validateTemplate(template); if (message == null) { if (!allowDuplicates) { for (Template t : getTemplates(name)) { remove(t); } } add(template); } else { throwReadException(null); } } } catch (ParserConfigurationException | IOException | SAXException e) { throwReadException(e); } }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
private void save(OutputStream stream) throws CoreException { try { DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance(); DocumentBuilder builder= factory.newDocumentBuilder(); Document document= builder.newDocument(); Element rootElement = document.createElement(fRootNodeName); document.appendChild(rootElement); Iterator<V> values= getValues().iterator(); while (values.hasNext()) { Object object= values.next(); Element element= document.createElement(fInfoNodeName); setAttributes(object, element); rootElement.appendChild(element); } Transformer transformer=TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ DOMSource source = new DOMSource(document); StreamResult result = new StreamResult(stream); transformer.transform(source, result); } catch (TransformerException | ParserConfigurationException e) { throw createException(e, Messages.format(CorextMessages.History_error_serialize, BasicElementLabels.getResourceName(fFileName))); } }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
private void load(InputSource inputSource) throws CoreException { Element root; try { DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); parser.setErrorHandler(new DefaultHandler()); root = parser.parse(inputSource).getDocumentElement(); } catch (SAXException | ParserConfigurationException | IOException e) { throw createException(e, Messages.format(CorextMessages.History_error_read, BasicElementLabels.getResourceName(fFileName))); } if (root == null) return; if (!root.getNodeName().equalsIgnoreCase(fRootNodeName)) { return; } NodeList list= root.getChildNodes(); int length= list.getLength(); for (int i= 0; i < length; ++i) { Node node= list.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element type= (Element) node; if (type.getNodeName().equalsIgnoreCase(fInfoNodeName)) { V object= createFromElement(type); if (object != null) { fHistory.put(getKey(object), object); } } } } rebuildPositions(); }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public JarPackageData readXML(JarPackageData jarPackage) throws IOException, SAXException { DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance(); factory.setValidating(false); DocumentBuilder parser= null; try { parser= factory.newDocumentBuilder(); } catch (ParserConfigurationException ex) { throw new IOException(ex.getLocalizedMessage()); } finally { // Note: Above code is OK since clients are responsible to close the stream } parser.setErrorHandler(new DefaultHandler()); Element xmlJarDesc= parser.parse(new InputSource(fInputStream)).getDocumentElement(); if (!JarPackagerUtil.DESCRIPTION_EXTENSION.equals(xmlJarDesc.getNodeName())) { throw new IOException(JarPackagerMessages.JarPackageReader_error_badFormat); } NodeList topLevelElements= xmlJarDesc.getChildNodes(); for (int i= 0; i < topLevelElements.getLength(); i++) { Node node= topLevelElements.item(i); if (node.getNodeType() != Node.ELEMENT_NODE) continue; Element element= (Element)node; xmlReadJarLocation(jarPackage, element); xmlReadOptions(jarPackage, element); xmlReadRefactoring(jarPackage, element); xmlReadSelectedProjects(jarPackage, element); if (jarPackage.areGeneratedFilesExported()) xmlReadManifest(jarPackage, element); xmlReadSelectedElements(jarPackage, element); } return jarPackage; }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public void writeXML(JarPackageData jarPackage) throws IOException { Assert.isNotNull(jarPackage); DocumentBuilder docBuilder= null; DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance(); factory.setValidating(false); try { docBuilder= factory.newDocumentBuilder(); } catch (ParserConfigurationException ex) { throw new IOException(JarPackagerMessages.JarWriter_error_couldNotGetXmlBuilder); } Document document= docBuilder.newDocument(); // Create the document Element xmlJarDesc= document.createElement(JarPackagerUtil.DESCRIPTION_EXTENSION); document.appendChild(xmlJarDesc); xmlWriteJarLocation(jarPackage, document, xmlJarDesc); xmlWriteOptions(jarPackage, document, xmlJarDesc); xmlWriteRefactoring(jarPackage, document, xmlJarDesc); xmlWriteSelectedProjects(jarPackage, document, xmlJarDesc); if (jarPackage.areGeneratedFilesExported()) xmlWriteManifest(jarPackage, document, xmlJarDesc); xmlWriteSelectedElements(jarPackage, document, xmlJarDesc); try { // Write the document to the stream Transformer transformer=TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, fEncoding); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount","4"); //$NON-NLS-1$ //$NON-NLS-2$ DOMSource source = new DOMSource(document); StreamResult result = new StreamResult(fOutputStream); transformer.transform(source, result); } catch (TransformerException e) { throw new IOException(JarPackagerMessages.JarWriter_error_couldNotTransformToXML); } }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public Element readXML() throws IOException, SAXException { DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance(); factory.setValidating(false); DocumentBuilder parser= null; try { parser= factory.newDocumentBuilder(); } catch (ParserConfigurationException ex) { throw new IOException(ex.getMessage()); } finally { // Note: Above code is OK since clients are responsible to close the stream } //find the project associated with the ant script parser.setErrorHandler(new DefaultHandler()); Element xmlJavadocDesc= parser.parse(new InputSource(fInputStream)).getDocumentElement(); NodeList targets= xmlJavadocDesc.getChildNodes(); for (int i= 0; i < targets.getLength(); i++) { Node target= targets.item(i); //look through the XML file for the javadoc task if ("target".equals(target.getNodeName())) { //$NON-NLS-1$ NodeList children= target.getChildNodes(); for (int j= 0; j < children.getLength(); j++) { Node child= children.item(j); if ("javadoc".equals(child.getNodeName()) && (child.getNodeType() == Node.ELEMENT_NODE)) { //$NON-NLS-1$ return (Element) child; } } } } return null; }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public static void writeDocument(Element javadocElement, String encoding, OutputStream outputStream) throws TransformerException { // Write the document to the stream Transformer transformer=TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, encoding); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount","4"); //$NON-NLS-1$ //$NON-NLS-2$ DOMSource source = new DOMSource(javadocElement.getOwnerDocument()); StreamResult result = new StreamResult(new BufferedOutputStream(outputStream)); transformer.transform(source, result); }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public Element createXML(JavadocOptionsManager store) throws ParserConfigurationException { DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance(); factory.setValidating(false); DocumentBuilder docBuilder= factory.newDocumentBuilder(); Document document= docBuilder.newDocument(); // Create the document Element project= document.createElement("project"); //$NON-NLS-1$ document.appendChild(project); project.setAttribute("default", "javadoc"); //$NON-NLS-1$ //$NON-NLS-2$ Element javadocTarget= document.createElement("target"); //$NON-NLS-1$ project.appendChild(javadocTarget); javadocTarget.setAttribute("name", "javadoc"); //$NON-NLS-1$ //$NON-NLS-2$ Element xmlJavadocDesc= document.createElement("javadoc"); //$NON-NLS-1$ javadocTarget.appendChild(xmlJavadocDesc); if (!store.isFromStandard()) xmlWriteDoclet(store, document, xmlJavadocDesc); else xmlWriteJavadocStandardParams(store, document, xmlJavadocDesc); return xmlJavadocDesc; }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public static void writeProfilesToStream(Collection<Profile> profiles, OutputStream stream, String encoding, IProfileVersioner profileVersioner) throws CoreException { try { final DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance(); final DocumentBuilder builder= factory.newDocumentBuilder(); final Document document= builder.newDocument(); final Element rootElement = document.createElement(XML_NODE_ROOT); rootElement.setAttribute(XML_ATTRIBUTE_VERSION, Integer.toString(profileVersioner.getCurrentVersion())); document.appendChild(rootElement); for (Profile profile : profiles) { if (profile.isProfileToSave()) { final Element profileElement= createProfileElement(profile, document, profileVersioner); rootElement.appendChild(profileElement); } } Transformer transformer=TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, encoding); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ transformer.transform(new DOMSource(document), new StreamResult(stream)); } catch (TransformerException | ParserConfigurationException e) { throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_serializing_xml_message); } }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public static List<Profile> readProfilesFromStream(InputSource inputSource) throws CoreException { final ProfileDefaultHandler handler= new ProfileDefaultHandler(); try { final SAXParserFactory factory= SAXParserFactory.newInstance(); final SAXParser parser= factory.newSAXParser(); parser.parse(inputSource, handler); } catch (SAXException | IOException | ParserConfigurationException e) { throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message); } return handler.getProfiles(); }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public void store(ContentAssistHistory history, StreamResult result) throws CoreException { try { DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance(); DocumentBuilder builder= factory.newDocumentBuilder(); Document document= builder.newDocument(); Element rootElement = document.createElement(NODE_ROOT); rootElement.setAttribute(ATTRIBUTE_MAX_LHS, Integer.toString(history.fMaxLHS)); rootElement.setAttribute(ATTRIBUTE_MAX_RHS, Integer.toString(history.fMaxRHS)); document.appendChild(rootElement); for (Entry<String, MRUSet<String>> entry : history.fLHSCache.entrySet()) { String lhs = entry.getKey(); Element lhsElement= document.createElement(NODE_LHS); lhsElement.setAttribute(ATTRIBUTE_NAME, lhs); rootElement.appendChild(lhsElement); for (String rhs : entry.getValue()) { Element rhsElement= document.createElement(NODE_RHS); rhsElement.setAttribute(ATTRIBUTE_NAME, rhs); lhsElement.appendChild(rhsElement); } } Transformer transformer=TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "no"); //$NON-NLS-1$ DOMSource source = new DOMSource(document); transformer.transform(source, result); } catch (TransformerException | ParserConfigurationException e) { throw createException(e, JavaTextMessages.ContentAssistHistory_serialize_error); } }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public ContentAssistHistory load(InputSource source) throws CoreException { Element root; try { DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); parser.setErrorHandler(new DefaultHandler()); root = parser.parse(source).getDocumentElement(); } catch (SAXException | ParserConfigurationException | IOException e) { throw createException(e, JavaTextMessages.ContentAssistHistory_deserialize_error); } if (root == null || !NODE_ROOT.equalsIgnoreCase(root.getNodeName())) return null; int maxLHS= parseNaturalInt(root.getAttribute(ATTRIBUTE_MAX_LHS), DEFAULT_TRACKED_LHS); int maxRHS= parseNaturalInt(root.getAttribute(ATTRIBUTE_MAX_RHS), DEFAULT_TRACKED_RHS); ContentAssistHistory history= new ContentAssistHistory(maxLHS, maxRHS); NodeList list= root.getChildNodes(); int length= list.getLength(); for (int i= 0; i < length; ++i) { Node lhsNode= list.item(i); if (lhsNode.getNodeType() == Node.ELEMENT_NODE) { Element lhsElement= (Element) lhsNode; if (NODE_LHS.equalsIgnoreCase(lhsElement.getNodeName())) { String lhs= lhsElement.getAttribute(ATTRIBUTE_NAME); if (lhs != null) { Set<String> cache= history.getCache(lhs); NodeList children= lhsElement.getChildNodes(); int nRHS= children.getLength(); for (int j= 0; j < nRHS; j++) { Node rhsNode= children.item(j); if (rhsNode.getNodeType() == Node.ELEMENT_NODE) { Element rhsElement= (Element) rhsNode; if (NODE_RHS.equalsIgnoreCase(rhsElement.getNodeName())) { String rhs= rhsElement.getAttribute(ATTRIBUTE_NAME); if (rhs != null) { cache.add(rhs); } } } } } } } } return history; }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public RefactoringSessionDescriptor readSession(final InputSource source) throws CoreException { fSessionFound= false; try { source.setSystemId("/"); //$NON-NLS-1$ createParser(SAXParserFactory.newInstance()).parse(source, this); if (!fSessionFound) throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IRefactoringCoreStatusCodes.REFACTORING_HISTORY_FORMAT_ERROR, RefactoringCoreMessages.RefactoringSessionReader_no_session, null)); if (fRefactoringDescriptors != null) { if (fVersion == null || "".equals(fVersion)) //$NON-NLS-1$ throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IRefactoringCoreStatusCodes.MISSING_REFACTORING_HISTORY_VERSION, RefactoringCoreMessages.RefactoringSessionReader_missing_version_information, null)); if (!IRefactoringSerializationConstants.CURRENT_VERSION.equals(fVersion)) throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IRefactoringCoreStatusCodes.UNSUPPORTED_REFACTORING_HISTORY_VERSION, RefactoringCoreMessages.RefactoringSessionReader_unsupported_version_information, null)); return new RefactoringSessionDescriptor(fRefactoringDescriptors.toArray(new RefactoringDescriptor[fRefactoringDescriptors.size()]), fVersion, fComment); } } catch (SAXParseException exception) { String message= Messages.format(RefactoringCoreMessages.RefactoringSessionReader_invalid_contents_at, new Object[] { Integer.toString(exception.getLineNumber()), Integer.toString(exception.getColumnNumber()) }); throwCoreException(exception, message); } catch (IOException | ParserConfigurationException | SAXException exception) { throwCoreException(exception, exception.getLocalizedMessage()); } finally { fRefactoringDescriptors= null; fVersion= null; fComment= null; fLocator= null; } return null; }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public void beginSession(final String comment, final String version) throws CoreException { if (fDocument == null) { try { fDocument= DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); fSession= fDocument.createElement(IRefactoringSerializationConstants.ELEMENT_SESSION); fSessionArguments= new ArrayList<>(2); Attr attribute= fDocument.createAttribute(IRefactoringSerializationConstants.ATTRIBUTE_VERSION); attribute.setValue(version); fSessionArguments.add(attribute); if (comment != null && !"".equals(comment)) { //$NON-NLS-1$ attribute= fDocument.createAttribute(IRefactoringSerializationConstants.ATTRIBUTE_COMMENT); attribute.setValue(comment); fSessionArguments.add(attribute); } fDocument.appendChild(fSession); } catch (DOMException exception) { throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IRefactoringCoreStatusCodes.REFACTORING_HISTORY_FORMAT_ERROR, exception.getLocalizedMessage(), null)); } catch (ParserConfigurationException exception) { throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IRefactoringCoreStatusCodes.REFACTORING_HISTORY_IO_ERROR, exception.getLocalizedMessage(), null)); } } }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
private Document getCachedDocument(final IPath path, final InputStream input) throws SAXException, IOException, ParserConfigurationException { if (path.equals(fCachedPath) && fCachedDocument != null) return fCachedDocument; DocumentBuilder parser= DocumentBuilderFactory.newInstance().newDocumentBuilder(); parser.setErrorHandler(new DefaultHandler()); final Document document= parser.parse(new InputSource(input)); fCachedDocument= document; fCachedPath= path; return document; }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public static Document convertModel(Iterable<? extends javax.lang.model.element.Element> declarations) throws ParserConfigurationException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Document model = factory.newDocumentBuilder().newDocument(); org.w3c.dom.Element modelNode = model.createElement(MODEL_TAG); XMLConverter converter = new XMLConverter(model); converter.scan(declarations, modelNode); model.appendChild(modelNode); return model; }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public static String xmlToString(Document model) { StringWriter s = new StringWriter(); DOMSource domSource = new DOMSource(model); StreamResult streamResult = new StreamResult(s); TransformerFactory tf = TransformerFactory.newInstance(); Transformer serializer; try { serializer = tf.newTransformer(); serializer.setOutputProperty(OutputKeys.INDENT, "yes"); serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "1"); serializer.transform(domSource, streamResult); } catch (Exception e) { e.printStackTrace(new PrintWriter(s)); } return s.toString(); }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
private boolean checkModel(List<TypeElement> rootElements, String expected, String name) throws Exception { Document actualModel = XMLConverter.convertModel(rootElements); InputSource source = new InputSource(new StringReader(expected)); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Document expectedModel = factory.newDocumentBuilder().parse(source); ByteArrayOutputStream out = new ByteArrayOutputStream(); StringBuilder summary = new StringBuilder(); summary.append("Test ").append(name).append(" failed; see console for details. "); boolean success = XMLComparer.compare(actualModel, expectedModel, out, summary, _ignoreJavacBugs); if (!success) { System.out.println("Test " + name + " failed. Detailed output follows:"); System.out.print(out.toString()); System.out.println("Cut and paste:"); System.out.println(XMLConverter.xmlToCutAndPasteString(actualModel, 0, false)); System.out.println("=============== end output ==============="); reportError(summary.toString()); } return success; }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public static String[] buildTables( final double unicodeValue, boolean usePredefinedRange, Environment env, String unicodeDataFileName) throws IOException { List<String> result = new ArrayList<>(); SAXParser saxParser = null; try { saxParser = SAXParserFactory.newInstance().newSAXParser(); } catch (ParserConfigurationException e) { e.printStackTrace(); return null; } catch (SAXException e) { e.printStackTrace(); return null; } DefaultHandler defaultHandler = new DefaultHandler() { @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (CHAR_ELEMENT.equals(qName)) { final String group = attributes.getValue(GROUP_CODE); if (env.hasCategory(group)) { final String codePoint = attributes.getValue(CODE_POINT); final String age = attributes.getValue(SINCE_UNICODE_VERSION); double ageValue = 0.0; try { ageValue = Double.parseDouble(age); } catch (NumberFormatException e) { e.printStackTrace(); } if (ageValue <= unicodeValue) { result.add(codePoint); } } } } }; try { saxParser.parse(new File(unicodeDataFileName), defaultHandler); } catch (SAXException e) { e.printStackTrace(); return null; } if (usePredefinedRange) { // predefined ranges - ISO control character (see // isIdentifierIgnorable(int)) result.add("0000..0008"); //$NON-NLS-1$ result.add("000E..001B"); //$NON-NLS-1$ result.add("007F..009F"); //$NON-NLS-1$ } return result.toArray(new String[result.size()]); }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public static Map decodeCodeFormatterOptions(String fileName, String profileName) { try { SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); final DecodeCodeFormatterPreferences preferences = new DecodeCodeFormatterPreferences(profileName); saxParser.parse(new File(fileName), preferences); return preferences.getEntries(); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (FactoryConfigurationError e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public static Map decodeCodeFormatterOptions(String zipFileName, String zipEntryName, String profileName) { ZipFile zipFile = null; BufferedInputStream inputStream = null; try { zipFile = new ZipFile(zipFileName); ZipEntry zipEntry = zipFile.getEntry(zipEntryName); if (zipEntry == null) { return null; } inputStream = new BufferedInputStream(zipFile.getInputStream(zipEntry)); SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); final DecodeCodeFormatterPreferences preferences = new DecodeCodeFormatterPreferences(profileName); saxParser.parse(inputStream, preferences); return preferences.getEntries(); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (FactoryConfigurationError e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (inputStream != null) { inputStream.close(); } if (zipFile != null) { zipFile.close(); } } catch (IOException e1) { // Do nothing } } return null; }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public IClasspathEntry decodeClasspathEntry(String encodedEntry) { try { if (encodedEntry == null) return null; StringReader reader = new StringReader(encodedEntry); Element node; try { DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); node = parser.parse(new InputSource(reader)).getDocumentElement(); } catch (SAXException | ParserConfigurationException e) { return null; } finally { reader.close(); } if (!node.getNodeName().equalsIgnoreCase(ClasspathEntry.TAG_CLASSPATHENTRY) || node.getNodeType() != Node.ELEMENT_NODE) { return null; } return ClasspathEntry.elementDecode(node, this, null/*not interested in unknown elements*/); } catch (IOException e) { // bad format return null; } }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
Document getDocument(String xmlPath) { try (InputStream is = createInputStream(xmlPath)) { if (is != null) { return DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(is)); } } catch (Exception e) { //ignored } return null; }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable