JDK-8230946 : Clarify security manager behaviour of a connected DatagramSocket and DatagramChannel
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 14
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2019-09-13
  • Updated: 2020-02-12
  • Resolved: 2019-10-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 14
14 b18Fixed
Related Reports
Blocks :  
CSR :  
Description
The longstanding behavior of DatagramSocket::receive is that it does
not perform a security manager check when connected ( which is similar
to DatagramChannel ). The security manager check is performed during
connect.

The specification for DatagramSocket::receive incorrectly implies that
the security manager check is always performed. Or at best, it is
ambiguous about the connected behavior. From DatagramSocket::receive -

   * If there is a security manager, a packet cannot be received if the
   * security manager's {@code checkAccept} method does not allow it.

DatagramSocket::receive should have wording similar to its NIO
counterpart, DatagramChannel, e.g.

   * <p> This method performs exactly the same security checks as the {@link
   * java.net.DatagramSocket#receive receive} method of the {@link
   * java.net.DatagramSocket} class.  That is, if the socket is not connected
   * to a specific remote address and a security manager has been installed
   * then for each datagram received this method verifies that the source's
   * address and port number are permitted by the security manager's {@link
   * java.lang.SecurityManager#checkAccept checkAccept} method.  The overhead
   * of this security check can be avoided by first connecting the socket via
   * the {@link #connect connect} method.

In fact, the discrepancy can be seen from the above two snippets. They
somewhat contradict each other.

---

A connected datagram socket /channel is a capability. It would be good
if the API noted this.
Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/6fc4a729763e User: dfuchs Date: 2019-10-08 15:37:53 +0000
08-10-2019