File tree Expand file tree Collapse file tree
packages/orchestrator/pkg/portmap Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,9 +22,7 @@ func newHandlers(ctx context.Context) *handlers {
2222
2323var _ portmap.PMAP_PROG_PMAP_VERS_handler = (* handlers )(nil )
2424
25- func (h * handlers ) PMAPPROC_NULL () {}
26-
27- func (h * handlers ) PMAPPROC_SET (mapping portmap.Mapping ) portmap.Xbool {
25+ func (h * handlers ) registerPort (mapping portmap.Mapping ) {
2826 h .lock .Lock ()
2927 defer h .lock .Unlock ()
3028
@@ -33,10 +31,18 @@ func (h *handlers) PMAPPROC_SET(mapping portmap.Mapping) portmap.Xbool {
3331 Vers : mapping .Vers ,
3432 Prot : mapping .Prot ,
3533 }] = portmap .Uint32 (mapping .Port )
34+ }
3635
37- return true
36+ func (h * handlers ) PMAPPROC_NULL () {}
37+
38+ // PMAPPROC_SET is not implemented, so we return false. It needs to remain unimplemented, as
39+ // implementing it allows attackers to register and possibly redirect NFS traffic.
40+ func (h * handlers ) PMAPPROC_SET (_ portmap.Mapping ) portmap.Xbool {
41+ return false
3842}
3943
44+ // PMAPPROC_UNSET is not implemented, so we return false. It serves no purpose, and implementing it
45+ // would allow attackers to remove port mappings, potentially disrupting services.
4046func (h * handlers ) PMAPPROC_UNSET (_ portmap.Mapping ) portmap.Xbool {
4147 return false
4248}
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ func TestPortmapRetrieval(t *testing.T) {
1111 t .Parallel ()
1212
1313 h := newHandlers (t .Context ())
14- h .PMAPPROC_SET (portmap.Mapping {
14+ h .registerPort (portmap.Mapping {
1515 Prog : 100003 ,
1616 Vers : 2 ,
1717 Prot : 1 ,
Original file line number Diff line number Diff line change @@ -46,14 +46,14 @@ func NewPortMap(ctx context.Context) *Server {
4646func (pm * Server ) RegisterPort (ctx context.Context , port uint32 ) {
4747 logger .L ().Info (ctx , "registering port" , zap .Uint32 ("port" , port ))
4848
49- pm .h .PMAPPROC_SET (rfc1057.Mapping {
49+ pm .h .registerPort (rfc1057.Mapping {
5050 Prog : nfs .Nfs3Prog ,
5151 Vers : nfs .Nfs3Vers ,
5252 Prot : rfc1057 .IPPROTO_TCP ,
5353 Port : port ,
5454 })
5555
56- pm .h .PMAPPROC_SET (rfc1057.Mapping {
56+ pm .h .registerPort (rfc1057.Mapping {
5757 Prog : 100005 , // mountd
5858 Vers : nfs .Nfs3Vers ,
5959 Prot : rfc1057 .IPPROTO_TCP ,
You can’t perform that action at this time.
0 commit comments