Test Case 1: Manipulation of P-Asserted-Identity Header

Last Updated : Apr 24, 2018 |

Use case

The P-Asserted-Identity header field can be used to present the identity of the originator of a request within a trusted network. Since the From header field is populated by the originating User-Agent, the From header field might not contain the actual identity. The P-Asserted-Identity header is established by means of authentication between the originating User-Agent and its outgoing proxy. The outgoing proxy then adds a P-Asserted-Identity header field to assert the identity of the originator to other proxies. 

  1. If the P-Asserted-Identity header field is not present, a proxy might add one containing at most one SIP or SIPS URI, and at most one telephone URL. 

  2. If the proxy received the message from an element that it does NOT trust and if there is a P-Asserted-Identity header present, the proxy MUST replace the SIP URI or remove it.

Script

within session "ALL"  //Looks into all the messages
{
	/* Message should be a request "act on request" and the messages coming towards the SBCE should be considered, i.e. the destination of the message should be SBCE "%DIRECTION="INBOUND". The actions are invoked as soon as the message comes from the wire(%ENTRY_POINT="AFTER_NETWORK") */
 		act on request where %DIRECTION="INBOUND" and %ENTRY_POINT="AFTER_NETWORK"
			{
			/*Checks if the first P-Asserted-Identity header is present/exists in
			the message. Each header is represented as %HEADERS[“<Header-name>”]
			[<Header position>].For headers such as From and Contact, the Header
			Position is always 1.For headers like Via and P-Asserted-Identity,
			the positions can range from 1 to n*/

					if(exists(%HEADERS["P-Asserted-Identity"][1]))then
					{
						remove(%HEADERS["P-Asserted-Identity"][1]); //Remove the header
					}
				 /*If the P-Asserted-Identity header is not found in the message*/
					else
					{
									/* Add a SIP and a telephone URI.*/
							%HEADERS["P-Asserted-Identity"][1] = "12345<sip:12345@192.168.150.150>";
							%HEADERS["P-Asserted-Identity"][2] = "tel:+14085264000"; 
					}
					}
			}

Description

The script looks into each message that comes in since the script acts on all sessions and checks if:

  1. The message is a request message.

  2. The message is coming to Avaya SBC.

When the above conditions are fulfilled and when the message comes from the wire, the basic sanity checks and DoS checks are performed on the message. The script checks if a P-Asserted-Identity header exists. If P-Asserted-Identity header exists, the script removes the header, else the script adds the header.

Limitations

To remove all the P-Asserted-Identity headers, you must know the maximum number of headers that must be present in the messages. You do not need to know the exact number of headers that come in because if you try to perform an operation on a header that does not exist, the operation is ignored.

Note:

If %HEADERS[“<Header-Name>”][<Header Position>] is already present, then the operation %HEADERS[“<Header-Name>”][<Header Position>] = <VAL> will modify the header.

If the header is not present in the message, %HEADERS[“<Header-Name>”][<Header Position>] = <VAL> adds the header to the message.