Sunday, August 10, 2014

Fortgate Patch Build numbering explanation

If you have been around fortinet for awhile, you will find the build numbers are  always increasing but not always in a +1  consecutive order for the OS that operates the fortigates appliances.

Using the fortiOS  4.0 MR3  train,  I  created a list all of the  builds starting with patch 0  thru 18



Fortinet will continue support under the 4.0MR3 release for 36 months. So  4.0 MR3 will most likely end somewhere b4 the end of 2014.


The FortiOS version 4.0 MR#3 was initially release 2011 3-18, and should have EoL 2014 4-19



Why gaps exists between builds,  has do to any of the following;


  • the build that was schedule to be made public, was retracted
  • the didn't pass QC, so another build was generated
  • more fixes where need or add 
  • or a new devices was introduce
Every time they patch the main code, and regardless if it was made public, the build # will always increment.

So for example from patch17 build 688 to  patch 18 build 689 was 1 increment.  ( There was just one build attempt ).

But between  patch10 build 639 to patch11 build 646, there was 7 unique builds before the patch11 was released.

A good indicator of major fixes or improvement, " when you see a big jump between public patch releases", that's a good indicator of some major work done to the OS version train.





Ken Felix
NSE ( network security expert) and Route/Switching Engineer
kfelix  -----a----t---- socpuppets ---dot---com

    ^    ^
=( +  - )=
      @
      /   \

















































































Saturday, August 9, 2014

Fortimail Interfaces Types as of 5.1.2 GA or higher

The fortimail appliance supports the following interfaces types;

1:standard port
2:redundant port ( 2 or more members )
3:vlan interfaces ( 802.1q tag )


The config  for any type is simple & easy. Please see examples


1> a standard static address


2> redundant ports ( with 2x member ports #3 & #4  )


3.a> 802.1q tagged vlan-interface ( bounded to a physical port #6 )


3.b> 802.1q tagged vlan-interface ( bounded to the redundant port0 )

Interfaces not supported are loopbacks ( even tho the unit has a hidden loopback interface btw ) , nor ether-bundled interfaces with 802.3ad. The redundant interface is ideal and  the best you can get,with  regards to redundancy.



Ken Felix
Freelance Network/Security Engineer
kfelix  -----a----t---- socpuppets ---dot---com

    ^    ^
=( +  - )=
      @
      /   \

Friday, August 8, 2014

Fortigate firewall policy matching order

A firewall policy on a fortigate is match in the follow order;


source and destination interfaces
source and destination address
service 
schedule
and finally we execute the action


Basically the same way you see the policy in the WebGUI display or CLI is the matching order.

Also multiple policies are are matched top to bottom & till one of 2 things happen;

1> it's match and the corresponding action  take place ( drop/accept/encrypt/etc.... ) and any security profiles are applied or traffic shapers


or

2> it's not matched and drop

Always place most specific 1st and more broader policies last . I always try to  get in a habit of placing vpn policies above everybody else.

Here's a typically policy with  #s indicating the matching order. I left  out the user identity stuff.



or  via cli


Keep the following in mind when troubleshooting fwpolicies;


1: RPF checks if applied comes 1st

2: next any  route lookup/decisions comes next ( can't do anything till we know where the packet is destination )

3: diag debug flow is your friend  ( learn how to use it )
http://socpuppet.blogspot.com/2013/03/flow-diagnostic-fortigate.html

4: the policy must be active in order for it to work ( will duh, but easily missed )

5:  the ordering of the policies are very crucial

6: the traffic has to reach the firewall in order to be process ( will again a big duh, but if you have no sessions no drops in the logs  if logging is enable, than you can assume the packet never made it  to you )


The diag sniffer packet command is your next best friend


I hope this post comes in handy for flow diagnostics.

Ken Felix
Security and Network  Engineer
kfelix  ----a---t---socpuppets ---d---o---t---com

     ^      ^
=(   -   - )=
         o
      /     \

Password creation guide lines by socpuppets


 Here's a recap on password security from socpuppets.  Password are the good and bad of good & bad security practices. Most ignore common sense and fail to change passwords on a regular schedule.

Password must meet at least 3 out of the following 4 complexity rules  to be considered a good and strong password.


1: At least one uppercase character ( A-Z)

2: At least one lowercase character ( a-z)


3: Contains  at least one special character ( !@#$%^&*()_+~)


4: Contains  at least one digit ( 0-9 )


5: should be at least 9 characters long ( longer is better )


6: should be at the most 64 characters  ( longer is ideal )


7: does not contain two consecutive  characters

e.g  ( 11,12,##,^^,KK,Kk,TT,12,34, etc )

8: you should never reuse a password ( a good systems would prevent replay )

9: passwords should not be shared between systems or applications  ( how many of us uses the same password for ;

ebay
facebook
twitter
webmail
systems or LAN access


Ken Felix
Freelance Network/Security Engineer
kfelix  -----a----t---- socpuppets ---dot---com

    ^    ^
=( #  # )=
      @
      /   \

Fortinet and understanding return codes

Fortinet Appliances typically provides some return codes if an error exists. This post will explain some of these return codes.

Everybody has seen the following message at one given time?



Okay simple , we have an return_code of 1. This was due primary because "seee" is not a configurable item. Basically I look at this return code  "1" as saying,

" hey dummy , check your command syntax "

The next return code  of  the # "8" means,  your option is incorrect or not expected. Take this dhcp6 server values that I will try to configure.



Both values where incorrectly format or expected, so the unit kicked out a "-8".


How about when we don't finish the command off correctly. Take this get system that was executed on a firewall.


So we got a "-160"  for the command executed via "get system" with nothing else specified.

Fortimail is similar btw,  but has noticeable differences. Take the same command "get system" The fortimail  appliance didn't display anything for reference and/or an  error / return code.

( normal expected err and return code, vrs  a no error or return code for the get system command syntax  )


Even between fortigate and fortimail, the  output could be very different



Even fortimail provides guidance on the expected value range sometimes for certain commands. Follow this output;

( take note  on the output range that it's expecting   1 thru 1440 )



On a fortigate it doesn't provide the same.



Bottom line,  get use to the  err and return code concept if you execute tasks from the command line.

The WebGUI typically provides no err or return codes in the output of bad execution, but will provide a popup window with summary or brief details.


e.g

( the values of x.x.x.x is not an valid address for a dhcp scope )


But the WebGUI is not faultless. Check out what happens if I place a dhcp scope range of 0.1.1.1 to 0.1.1.2.



note:  no error and the comman completes.


But from the cli, the console would display a error.




 Ken Felix
 Freelance Network & Security Engineer
 kfelix -a--t- socpuppets ---d--o--t--- com

   ^      ^
=( !   ! )=
       o 
      /  \

How do do config archival with cisco router/switch but without using rancid

In this post , we will look at just one way you can get creative with configuration changes archival.

This method works when ever  anybody makes configurations change and by exiting the configuration mode.


1st, here's the goal, we want to  execute config changes archival &  backups to 2 rancid-like nms  hosts

2nd, we will use  scp   for the protection of the backup configuration file  & transfer of the data and to 2 or more backup sources

3rd, we will also  execute at a pre-arrange time via kron, an automatic configuration backup via pushing the configuration to our two NMS hosts

4rd, restrict the user from actually logging into the NMS host
 

All of the above will be done via the cisco IOS  following features;  1:kron scheduler , 2:tclsh and  the cisco 3:eem ( embedded event manager )  and on our linux server we will install rssh

Here's the topology of our router and 2x NMS hosts & a typical switch/router.



note : The 2 NMS hosts have pre-defined user  ( rancid ) that's been enabled for "scp" and not listed in the superuser doers file & we have installed rssh  for added security and restrictions.


Okay let's look at the eem script that we use for the backup via the kron job.


This was as simple as I can make it,
  •   trigger on a syslog mesg
  •   execute the tclsh that we copy to the local disk
  •   optional, I generate my own log messages 


And here's the tcl script. Once again a simple script not overly complex.

set date [clock format [clock seconds] -format {%Y%m%d%T}]
set hostname [info hostname]
set file "${hostname}.${date}.cfg"
exec "copy running-config scp://rancid:apassword@10.200.40.67/mycfg/$file"
exec "copy running-config scp://rancid:apassword@10.200.41.67/mycfg/$file"


Okay what's happening here,

  • we define a few variable like time& date and the hostname  plus target filename
  • we use scp to copy the  config to the scp server

For the  archival, we will dump the config every time the a administrator exit config mode. The kron scheduler is quite simple. We create a policy-list and policy and match the 2 for execution at our select time.




NOTE: This step is not really required, but it's nice to write out the configurations regardless if any write action has taken place for any extended periods imho.

 The cisco archive is limited to writing to "ONE" target path. So if you have redundant backup  targets like 2 or more, cisco archive is of no use.

Kron execution of the  tcl shell ensure your have a backup made regardles if EEM is working or not.

 
One last tidbit, ensure you set the username for EEM applet execution. In this case I have an account on the cisco routers and switches named "rancid". This user will need the correct priv level for execution of the  EEM cli actions.

Without defining a user, your EEM applets will fail!

e.g

config t

  username  rancid  secret 123456 priv 15 
  event  manager session cli username rancid

end


fwiw;

I like my approach over using pure rancid, since rancid is a pull process, where-as this  a "push" operation.

You don't need to manipulate anything or run any cron schedule on a unix/linux host,  and all cfgs are sent immediately upon a  execution of a confiiguration mode.

Also with this approach you don't need to install any type rancid program or make modification when a new host is installed or deleted from the network.  You can easily serve the configurations diff directly via HTTPS and allow access for your users to review and download  the configurations files. You could easily write a cgi script that would diff and  display the differences between the two latest files.

You can find more information on rancid here; http://en.wikipedia.org/wiki/RANCID

Cisco EEM here; http://www.cisco.com/c/en/us/products/ios-nx-os-software/ios-embedded-event-manager-eem/index.html

You can learn more about cisco tcl via the following;
http://www.cisco.com/c/en/us/td/docs/ios-xml/ios/ios_tcl/command/ios-tcl-cr-book/ios-tcl-cr-c1.html


BTW:

The following  EEM applet was use earlier, but it more complex and was generate a loop.

( notice we match our EEM trigger action  on the syslog message "Building configuration" )






NOTE:  You can modify the above EEM applet  from a "write" operation to any time a admin enters and/or leave  configuration mode via matching one of these patterns.

e.g

Last note, keep in mind most current ios software code allows for archival,  but not all software release supports  kron or the cisco EEM.  ( e.g cisco 2960S lanbase )

=====================================================================


The rssh  ( restricted shell) is easy to setup btw. Here's a brief summary for a unix host.

1st install the application and supporting files via APT.

apt-get install rssh


Next , vi /etc/rssh.cfg and s uncomment the following line;

allowscp
  
Next install the rssh for the user account that will conduct the scp copy. Here's my user account on a ubuntu server;



And here's what happen when rancid trys to ssh ;

You can find information on rssh here ; http://linux.die.net/man/1/rssh

Conclusion:

So all security risk are mitigated and you have restrict the backup account to just a scp. With the $t & $h, variables, we have a  time-stamp and unique name for the hosts that pushes the configuration.

EEM is very powerful and by combination of the  archive we can do many things with  backing up configurations.

The cisco archive is limited to one path destination, but EEM gives us the ability to make backups to 2 or  more locations.

Almost all cisco router/swicthes support tcl


Ken Felix
Security and Network  Engineer
kfelix  ----a---t---socpuppets ---d---o---t---com

     ^      ^
=(   -   - )=
         o
      /     \



Thursday, August 7, 2014

Your fortigate is not as secured as you think, when it comes to HTTPS

In this blog, I will show you a simple means on how someone who has access to a fortigate, can actually sniff your encrypted session  traffic by grabbing the private-server key. We will use the hidden command fnsysctl , and  use tshark  on a unix host to accomplish our hacking. You can also execute this via wireshark btw.


1st Let's look at where the key is stored. The local directory /tmp has quite a few cool stuff. Mainly keys :). Why fortinet choose to place a security item like private-key for HTTPS in this directory; " is mind boggling to say the least"



fnsysctl ls /tmp/

NOTE: I circled the  server-side private key and pointed out the  certificate. We only need the  key btw.


Okay so now we know where the key is. We will grab that key and installed it on our unix host. Now all we need to do is to capture https traffic to the fortigate. In my case, I'm writing a packet capture by using the expression.

(on my macbook air )
tcpdump -w http1.pcap -s 1500 -i en4

Okay, now that we have a packet capture, we now only need to  decode the https traffic using the private-key we grabbed earlier  from the /tmp directory.

(on my linux forsenic host that we will use to de-encrypt the traffic )

 tshark -o "ssl.keys_list: x.x.x.x,443,http,./server.key" -r http.pcap  -R http  -V > myblog

The x.x.x.x would  equal your fortigate ip_address

( results )

Okay here's a screen capture of the HTTP header from the POST with the username credentials from  the packet-capture from above. I sanitized the ip_address for security reasons.




Okay here's a screen capture of the HTTP header from the POST with the username  we created and his password.



Okay now that you see the fortigate is weak,  and is very in-secured from password grabbing. And let me remind you ; " this is appliance from a major security vendor ".



Okay now I will show you some ways to reduce this risk


1: define trusted hosts for users logins

Yes this will not keep some one from sniffing the password , but  would reduce from where they can login  from to begin with

2: reduce the number of "admin" or "super-user accounts"

Once again , does nothing from preventing someone from  sniffing the password

3: reduce the number of interfaces that has the set allowaccess  https  enabled 

Once again does nothing from preventing a person from sniffing the traffic and from gaining the password. This just restricts the number of interfaces that are exposed.

4: You can reduce this risk by deploying SSH only access 

Yes that would suck to have to configure all items via CLI on a firewall appliance with a WebGUI.


NOTE: installing  a  readonly account,  does NOT prevent a person from logining in and gaining the  private.key via ssh or executing a local WebGUI console. The risk is with someone gaining access to the server HTTPS private-key.


Finally note, this was done on a Fortigate run 4.0 MR3p17


Ken Felix
Network & Security Engineer
kfelix  ----a---t---socpuppets ---d---o---t---com

     ^      ^
=(   -   - )=
         o
      /     \